Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Database/World Building

Development::Database/World Building World Building forum, dedicated to the EQEmu MySQL Database. Post partial/complete databases for spawns, items, etc.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-11-2004, 08:29 AM
sotonin
Demi-God
 
Join Date: May 2004
Posts: 1,177
Default Classic DB Spawngroup Fix

Found a bug with the log parser we use to make the database. It seems spawngroups were being assigned 50% chance per npc, regardless of how many npcs were in the spawngroup. This caused a greater than 100% chance on groups with more than 2 npcs in it. Thus making the lower mobs on the list not spawn. I created a php script to fix this. Tested it today seems to work great. All our future databases will have this run before release now that we've identified the problem. You must have a php capable web server to run this script.

Fill it in with your own database mysql connect info.

Code:
<? 

class database {
	function database(){
		$dbhost = 'localhost';
		$dbuser = 'dbuser';
		$dbpass = 'dbpass';
		$db = 'database';
		$link = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($db) or die("Failed to select database with error: ".mysql_error());
	}

	function openConnectionWithReturn($query){
		$result=@mysql_query($query) or die("Query failed with error: ".mysql_error());
		return $result;
	}

	function openConnectionNoReturn($query){
		@mysql_query($query) or die("Query failed with error: ".mysql_error());
	}
}

$database = new database();

$from =0;
$from2 = 0;

$count_q = "SELECT * FROM spawngroup";
$count_r = mysql_query($count_q);
$count_x = mysql_num_rows($count_r);

while($from2 < $count_x) {
	$max_results = $from + 1000;
	
	$query = "SELECT * FROM spawngroup ORDER by id ASC LIMIT $from, $max_results";
	$result = mysql_query($query);
	
	while($row = mysql_fetch_array($result)){
		$spawngroupID = $row['id'];
		
		$query2 = "SELECT * FROM spawnentry WHERE spawngroupID='$spawngroupID'";
		$result2 = mysql_query($query2);
		$count = mysql_num_rows($result2);
		
		echo($spawngroupID . "<Br />");
		if (!$result2 || ($count<1)) {
			?>ERROR <?
		} else {
			if ($count==1) {
				$percent = 100;
			} else {
				$percent = (100/$count);
				$percent = round($percent);
			}
		
			while(($percent*$count)>100) {
				$percent=$percent-1;
			}
		
			$leftover = (100 - ($percent * $count));
			$final = $percent+$leftover;
			
			$i = 1;
		
			while($row2 = mysql_fetch_array($result2)){
				$npcID = $row2['npcID'];
				$chance = $row2['chance'];
			
				if (($count==1) && ($chance!=100)) {
					$query3 = "UPDATE spawnentry SET chance=100 WHERE spawngroupID=$spawngroupID AND npcID=$npcID";
				}
			
				if (($count==2) && ($chance!=50)) {
					$query3 = "UPDATE spawnentry SET chance=50 WHERE spawngroupID=$spawngroupID AND npcID=$npcID";
				} else {
					if (($i==$count)) {
						$query3 = "UPDATE spawnentry SET chance=$final WHERE spawngroupID=$spawngroupID AND npcID=$npcID";
					} else {
						$query3 = "UPDATE spawnentry SET chance=$percent WHERE spawngroupID=$spawngroupID AND npcID=$npcID";
					}
					$result3 = @mysql_query($query3);
					$i++;
				}
			}
		}
	}
	$from2 = $from;
	$from = $from + 1000;
}
	
	?>DONE!
Use it at your own risk. i've tested it but who knows what it may do for you. ALWAYS back up your database before doing something big like this.

hope it helps!
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 07:33 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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3