Post Pacific  

Go Back   Post Pacific > Lineage 2 > Lineage 2 Server Modifications ONLY!
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 22.06.2006, 11:36   #1
empathon
Архивный участник
 
Join Date: Feb 2006
Posts: 136
Default [share]"full" c4 itemdata

Some small share. Maybe someone will need this.
Php generator to create itemdata from client files (use files in ASCI!):
Code:
<?php

//*************** Itemdata generator by empathon (c) 2006 ***********************//
//*******************************************************************************//

//Functions
function cut($string, $open_tag, $end_tag)
{
	$pos_start = strpos($string, $open_tag) + strlen($open_tag);
	$pos_end = strpos($string, $end_tag, $pos_start);
	$cut = substr($string, $pos_start, $pos_end - $pos_start);
	return $cut;
}

//Main program
if (file_exists("itemname-e.txt")&&file_exists("weapongrp.txt")&&file_exists("armorgrp.txt")&&file_exists("etcitemgrp.txt"))
{
	echo "Files OK...";
	$itemnames = file ('itemname-e.txt');
	$item_count = sizeof($itemnames);
	echo $item_count.' items
';
	set_time_limit(360);
	$ids = array_fill( 0, $item_count, 0);
	$names = array_fill( 0, $item_count, 'abc');
	$used_names = array_fill( 0, $item_count + 1, 'abc');
	for ($i = 0; $i < $item_count; $i++)
	{
		$id = cut ($itemnames[$i], "id=", "	");
		if (cut($itemnames[$i], "additionalname=[", "]	"))
		{
			$name = cut ($itemnames[$i], "name=[", "]").'_'.cut ($itemnames[$i], "additionalname=[", "]	");
		}
		else
		{
			$name = cut ($itemnames[$i], "name=[", "]");
		}
		echo " id =".$id." name =".$name.'
';
		$ids[$i] = $id;
		$names[$i] = $name;
	}
	$max_id = $id;
	$sorted_ids = $ids;
	sort($sorted_ids, SORT_NUMERIC);
	$weapon = file('weapongrp.txt');
	$weapon_count =sizeof($weapon);
	$weapons = array_fill( 0, $weapon_count + 1, 0);
	$armor = file('armorgrp.txt');
	$armor_count =sizeof($armor);
	$armors = array_fill( 0, $armor_count + 1, 0);
	$etcitem = file('etcitemgrp.txt');
	$etcitem_count =sizeof($etcitem);
	$etcitems = array_fill( 0, $etcitem_count + 1, 0);
	for ($i = 1; $i <= $weapon_count; $i++)
	{
		$weapons[$i] = cut($weapon[$i-1], "object_id=", "	");
	}
	for ($i = 1; $i <= $armor_count; $i++)
	{
		$armors[$i] = cut($armor[$i-1], "object_id=", "	");
	}
	for ($i = 1; $i <= $etcitem_count; $i++)
	{
		$etcitems[$i] = cut($etcitem[$i-1], "object_id=", "	");
	}
	$idata = fopen("itemdata_gen.txt", "w");
	flock($idata, 2);
	$ws = 1;
	for ($i = 0; $i < $item_count; $i++)
	{
	switch (TRUE) {
		case array_search( $sorted_ids[$i], $weapons):
			$k = array_search( $sorted_ids[$i], $weapons) - 1;
			$n = array_search($sorted_ids[$i], $ids);
			$name = $names[$n];
			$name = str_replace(" - ", "-", $name);
			$name = strtolower(str_replace(" ", "_", $name));
//			list ($name, $used_names, $ws) = name_check($name, $used_names, $ws);
			if ( $name == '')
			{
				$unique_name = 'item_'.rand(0, 1000);
				$used_names[$ws] = $unique_name;
				$ws = $ws + 1;
			}
			elseif (!array_search($name, $used_names))
			{
				$unique_name = $name;
				$used_names[$ws] = $unique_name;
				$ws = $ws + 1;
			}
			else
			{
				for ( $p = 2; ; $p++)
				{
				$unique_name = $name.'_'.$p;
				if (!array_search($unique_name, $used_names))
				{
					$used_names[$ws] = $unique_name;
					$ws = $ws + 1;
					break;
				}
			}
			}
			$slot = cut( $weapon[$k], "body_part=", "	");
			$ss = cut( $weapon[$k], "soulshot_count=", "	");
			$sps = cut( $weapon[$k], "spiritshot_count=", "	");
			$price = 1000;	//You should import that from orginal file
			$grade = cut( $weapon[$k], "crystal_type=", "	");
			if (cut( $weapon[$k], "crystallizable=", "	"))
			{
				$crystal_count = 1000;	//You should import that from orginal file...
			}
			else
			{
				$crystal_count = 0;
			}
			$physical_damage = cut( $weapon[$k], "physical_damage=", "	");
			$random_damage = cut( $weapon[$k], "random_damage=", "	");
			$type = cut( $weapon[$k], "weapon_type=", "	");
			$penetrate = 0;	//You should import that from orginal file
			$critical = cut( $weapon[$k], "critical=", "	");
			$hit_modify = cut( $weapon[$k], "hit_modify=", "	");
			$avoid_modify = cut( $weapon[$k], "avoid_modify=", "	");
			if ($type == 'dual' or $type == 'dualfist')
			{
				$dual_fhit_rate = 50;	//You should import that from orginal file
			}
			else
			{
				$dual_fhit_rate = 0;
			}
			switch ($type)
			{
				case 'sword':
					$attack_range = 40;
					$effective_range = 48;
					$damage_range = '{0;0;40;120}';
				break;
				case 'pole':
					$attack_range = 80;
					$effective_range = 96;
					$damage_range = '{0;0;66;120}';
				break;
				case 'bow':
					$attack_range = 500;
					$effective_range = 600;
					$damage_range = '{0;0;10;0}';
				break;
				case 'blunt':
					$attack_range = 40;
					$effective_range = 48;
					$damage_range = '{0;0;40;120}';
				break;
				case 'fist':
					$attack_range = 40;
					$effective_range = 48;
					$damage_range = '{0;0;40;120}';
				break;
				case 'dualfist':
					$attack_range = 40;
					$effective_range = 48;
					$damage_range = '{0;0;32;120}';
				break;
				case 'dual':
					$attack_range = 40;
					$effective_range = 48;
					$damage_range = '{0;0;44;120}';
				break;
				case 'dagger':
					$attack_range = 40;
					$effective_range = 48;
					$damage_range = '{0;0;40;120}';
				break;
				case 'etc':
					$attack_range = 40;
					$effective_range = 48;
					$damage_range = '{0;0;40;120}';
				break;
				default:
					$attack_range = 0;
					$effective_range = 0;
					$damage_range = '{}';
			}
			if ($type == 'bow')
			{
				$reuse_delay = 1500;	//You should import that from orginal file
			}
			else
			{
				$reuse_delay = 0;	//Some pole have reuse_delay=2, import that from orginal file
			}
			if ($slot == '{none}')
			{
				$equip_pet = '{@pet_}';	//You should import that from orginal file
			}
			else
			{
				$equip_pet = '{0}';
			}
			$attack_speed = cut( $weapon[$k], "attack_speed=", "	");
			$magical_damage = cut( $weapon[$k], "magical_damage=", "	");
			$shield_defense = cut( $weapon[$k], "shield_defense=", "	");
			if ($shield_defense == '0')
			{
				$kind = 'weapon';
			}
			else
			{
				$kind = 'armor';
			}
			if ($magical_damage > $physical_damage && $kind == 'weapon')
			{
				$magic_weapon = 1;
			}
			else
			{
				$magic_weapon = 0;
			}
			$shield_defense_rate = cut( $weapon[$k], "shield_defense_rate=", "	");
			$weight = cut( $weapon[$k], "weight=", "	");
			$material = cut( $weapon[$k], "material_type=", "	");
			$mp_consume = cut( $weapon[$k], "mp_consume=", "	");
			$durability = cut($weapon[$k], "durability=", "	");
			fwrite($idata, "item_begin	$kind	$sorted_ids[$i]	[$unique_name]	item_type=$kind	slot_bit_type=$slot	armor_type=none	etcitem_type=none	blessed=0	weight=$weight	default_action=action_equip	consume_type=consume_type_normal	initial_count=1	maximum_count=1	soulshot_count=$ss	spiritshot_count=$sps	immediate_effect=1	price=0	default_price=$price	item_skill=[none]	critical_attack_skill=[none]	material_type=$material	crystal_type=$grade	crystal_count=$crystal_count	is_trade=1	is_drop=1	is_destruct=1	physical_damage=$physical_damage	random_damage=$random_damage	weapon_type=$type	can_penetrate=$penetrate	critical=$critical	hit_modify=$hit_modify.75	avoid_modify=$avoid_modify	dual_fhit_rate=$dual_fhit_rate	shield_defense=$shield_defense	shield_defense_rate=$shield_defense_rate	attack_range=$attack_range	effective_range=$effective_range	damage_range=$damage_range	attack_speed=$attack_speed	reuse_delay=$reuse_delay	mp_consume=$mp_consume	magical_damage=$magical_damage	durability=$durability	damaged=0	physical_defense=0	magical_defense=0	mp_bonus=0	category={}	enchanted=0	html=[item_default.htm]	equip_pet=$equip_pet	magic_weapon=$magic_weapon	item_end\n");
			break;
		case array_search( $sorted_ids[$i], $armors):
			$k = array_search( $sorted_ids[$i], $armors) - 1;
			$n = array_search($sorted_ids[$i], $ids);
			$name = $names[$n];
			$name = str_replace(" - ", "", $name);
			$name = strtolower(str_replace(" ", "_", $name));
//			list ($name, $used_names, $ws) = name_check($name, $used_names, $ws);
			if ( $name == '')
			{
				$unique_name = 'item_'.rand(0, 1000);
				$used_names[$ws] = $unique_name;
				$ws = $ws + 1;
			}
			elseif (!array_search($name, $used_names))
			{
				$unique_name = $name;
				$used_names[$ws] = $unique_name;
				$ws = $ws + 1;
			}
			else
			{
				for ( $p = 2; ; $p++)
				{
				$unique_name = $name.'_'.$p;
				if (!array_search($unique_name, $used_names))
				{
					$used_names[$ws] = $unique_name;
					$ws = $ws + 1;
					break;
				}
				}
			}
			$type = cut( $armor[$k], "armor_type=", "	");
			$slot = cut( $armor[$k], "body_part=", "	");
			if ( $slot == '{rfinger;lfinger}' or $slot == '{neck}' or $slot == '{hair}' or $slot == '{rear;lear}')
			{
				$kind = 'accessary';
			}
			else
			{
				$kind = 'armor';
			}
			$weight = cut( $armor[$k], "weight=", "	");
			$price = 1000;	//You should import that from orginal file
			$material = cut( $armor[$k], "material_type=", "	");
			$grade = cut( $armor[$k], "crystal_type=", "	");
			if (cut( $armor[$k], "crystallizable=", "	"))
			{
				$crystal_count = 1000;	//You should import that from orginal file...
			}
			else
			{
				$crystal_count = 0;
			}
			$avoid_modify = cut( $armor[$k], "avoid_modify=", "	");
			$equip_pet = '{0}'; //You should import that from orginal file
			$default_action = 'action_equip';	//Also this
			$physical_defense = cut( $armor[$k], "physical_defense=", "	");
			$magical_defense = cut( $armor[$k], "magical_defense=", "	");
			$mp_bonus = cut( $armor[$k], "mp_bonus=", "	");
			$durability = cut( $armor[$k], "durability=", "	");
			fwrite($idata, "item_begin	$kind	$sorted_ids[$i]	[$unique_name]	item_type=$kind	slot_bit_type={$slot}	armor_type=$type	etcitem_type=none	blessed=0	weight=$weight	default_action=$default_action	consume_type=consume_type_normal	initial_count=1	maximum_count=1	soulshot_count=0	spiritshot_count=0	immediate_effect=1	price=0	default_price=$price	item_skill=[none]	critical_attack_skill=[none]	material_type=$material	crystal_type=$grade	crystal_count=$crystal_count	is_trade=1	is_drop=1	is_destruct=1	physical_damage=0	random_damage=0	weapon_type=none	can_penetrate=0	critical=0	hit_modify=0	avoid_modify=$avoid_modify	dual_fhit_rate=0	shield_defense=0	shield_defense_rate=0	attack_range=0	effective_range=0	damage_range={}	attack_speed=0	reuse_delay=0	mp_consume=0	magical_damage=0	durability=$durability	damaged=0	physical_defense=$physical_defense	magical_defense=$magical_defense	mp_bonus=$mp_bonus	category={}	enchanted=0	html=[item_default.htm]	equip_pet={$equip_pet}	magic_weapon=0	item_end\n");
			break;
		case array_search( $sorted_ids[$i], $etcitems):
			$k = array_search( $sorted_ids[$i], $etcitems) - 1;
			$n = array_search($sorted_ids[$i], $ids);
			$name = $names[$n];
			$name = str_replace(" - ", "-", $name);
			$name = strtolower(str_replace(" ", "_", $name));
//			list ($name, $used_names, $ws) = name_check($name, $used_names, $ws);
			if ( $name == '')
			{
				$unique_name = 'item_'.rand(0, 1000);
				$used_names[$ws] = $unique_name;
				$ws = $ws + 1;
			}
			elseif (!array_search($name, $used_names))
			{
				$unique_name = $name;
				$used_names[$ws] = $unique_name;
				$ws = $ws + 1;
			}
			else
			{
				for ( $p = 2; ; $p++)
				{
				$unique_name = $name.'_'.$p;
				if (!array_search($unique_name, $used_names))
				{
					$used_names[$ws] = $unique_name;
					$ws = $ws + 1;
					break;
				}
			}
			}
			$type = cut( $etcitem[$k], "etcitem_type=", "	");
			$weight = cut( $etcitem[$k], "weight=", "	");
			$consume = cut( $etcitem[$k], "consume_type=", "	");
			if ($consume == "consume_type_stackable")
			{
				$max_count = 20;
			}
			else
			{
				$max_count = 1;
			}
			$material = cut( $etcitem[$k], "material_type=", "	");
			$equip_pet = '{0}'; //You should import that from orginal file
			if ($sorted_ids[$i] == 57)
			{
				$kind = 'asset';
				$default_action = 'action_none';
			}
			else
			{
				$kind = 'etcitem';
				$default_action = 'action_none';	//Also this
			}
			$durability = cut($etcitem[$k], "durability=", "	");
			fwrite($idata, "item_begin	$kind	$sorted_ids[$i]	[$unique_name]	item_type=$kind	slot_bit_type={none}	armor_type=none	etcitem_type=$type	blessed=0	weight=$weight	default_action=$default_action	consume_type=$consume	initial_count=1	maximum_count=$max_count	soulshot_count=0	spiritshot_count=0	immediate_effect=1	price=0	default_price=1	item_skill=[none]	critical_attack_skill=[none]	material_type=$material	crystal_type=none	crystal_count=0	is_trade=1	is_drop=1	is_destruct=1	physical_damage=0	random_damage=0	weapon_type=none	can_penetrate=0	critical=0	hit_modify=0	avoid_modify=0	dual_fhit_rate=0	shield_defense=0	shield_defense_rate=0	attack_range=0	effective_range=0	damage_range={}	attack_speed=0	reuse_delay=0	mp_consume=0	magical_damage=0	durability=$durability	damaged=0	physical_defense=0	magical_defense=0	mp_bonus=0	category={}	enchanted=0	html=[item_default.htm]	equip_pet={$equip_pet}	magic_weapon=0	item_end\n");
			break;
	}
	}
	echo "Done.";
	flock($idata, 3);
	fclose($idata);
}
else
{
	echo "Client files not full. Script needs itemnames-e.txt, weapongrp.txt, armorgrp.txt and etcitemgrp.txt\n";
}
?>
Script to add missing items form generated file to your Itemdata (use ASCI format!):
[php:1:288f21022f]
<?php
//*************** Importing items by empathon (c)2006************//
//************************************************** *************//
function cut_id($string)
{
$pos_start = strpos($string, ' ', 11);
$pos_end = strpos($string, ' ', $pos_start + 1);
$cut = substr($string, $pos_start + 1, $pos_end - $pos_start -1);
return $cut;
}
//Main script
if (file_exists("itemdata_gen.txt")&&file_exists("ite mdata.txt"))
{
echo "Files OK...";
$itemdata_gen = file ('itemdata_gen.txt');
$itemdata_org = file ('Itemdata.txt');
$item_count_gen = sizeof($itemdata_gen);
$item_count_org = sizeof($itemdata_org);
$missing = $item_count_gen - $item_count_org;
echo "$item_count_org items in orginal file and $item_count_gen in generated file. Missing $missing items in orginal file.
";
// set_time_limit(360);
$ids_gen = array_fill( 0, $item_count_gen, 0);
$ids_org = array_fill( 0, $item_count_org + 1, 0);
if ($item_count_gen > $item_count_org)
{
$idata = fopen("itemdata_import.txt", "w");
flock($idata, 2);
for ($i = 0; $i < $item_count_gen; $i++)
{
$ids_gen[$i] = cut_id($itemdata_gen[$i]);
}
for ($i = 1; $i < $item_count_org; $i++)
{
$ids_org[$i] = cut_id($itemdata_org[$i]);
}
for ($i = 0; $i < $item_count_gen; $i++)
{

if (array_search( $ids_gen[$i], $ids_org))
{
$id = array_search( $ids_gen[$i], $ids_org);
fwrite($idata, $itemdata_org[$id]);
}
else
{
fwrite($idata, $itemdata_gen[$i]);
}
}
flock($idata, 3);
fclose($idata);
}
else
{
echo "Nothing to import.";
}
}
else
{
echo "Files incomplite.";
}
?>
[/php:1:288f21022f]
Script to correct wrong lines like: item_begin armor 54534 [something] item_type=weapon ... :
[php:1:288f21022f]
<?php
//*************** Importing names by empathon (c)2006************//
//************************************************** *************//
function cut($string)
{
$pos_start = strpos($string, ' ');
$pos_end = strpos($string, ' ', $pos_start + 1);
$kind = substr($string, $pos_start + 1, $pos_end - $pos_start - 1);
$pos_start = strpos($string, 'item_type=') + 10;
$itemdata_1 = substr($string, $pos_end + 1, $pos_start - $pos_end - 1);
$pos_end = strpos($string, ' ', $pos_start);
$item_type = substr($string, $pos_start, $pos_end - $pos_start);
$itemdata_2 = substr($string, $pos_end + 1, strlen($string));
return array($kind, $itemdata_1, $item_type, $itemdata_2);
}
//Main script
if (file_exists("itemdata.txt"))
{
echo "Files OK...";
$itemdata = file ('Itemdata.txt');
$item_count = sizeof($itemdata);
$idata = fopen("itemdata_fixed.txt", "w");
flock($idata, 2);
$fixed = 0;
for ($i = 0; $i < $item_count; $i++)
{
list ($kind, $itemdata_1, $item_type, $itemdata_2) = cut($itemdata[$i]);
if ($kind != $item_type)
{
fwrite($idata, "item_begin $kind $itemdata_1$kind $itemdata_2");
$fixed++;
}
else
{
fwrite($idata, $itemdata[$i]);
;}
}
echo "$fixed items type fixed.";
flock($idata, 3);
fclose($idata);
}
else
{
echo "Files incomplite.";
}
?>
[/php:1:288f21022f]
And generated files. I hope it will be usefull.
Edit: Fixed width

Вложения из исходного сообщения (сами файлы в копии отсутствуют):
itemdata_fixed_139.rar — 115508 байт
itemdata_gen_161.rar — 101699 байт
empathon is offline  
 


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. The time now is 22:17.