Xari0n
14.07.2006, 20:08
The script is universal for converting npcdata and itemdata, check it.
[php:1:0b4601f89b]<pre>
<?php
// Xelat Copyright(c) 2006
//[email protected]
//ICQ 195187980
$orig_dir = "c4\\orig";
$off_dir = "c4\\off";
$out_dir = "c4";
$include["npc"] = explode(",","level,acquire_exp_rate,exp,acquire_sp,clan,ignore_ clan_list,clan_help_range,slot_chest,slot_rhand,sl ot_lhand,skill_list,npc_ai,category,race,sex,undyi ng,can_be_attacked,corpse_time,no_sleep_mode,agro_ range,ground_high,ground_low,org_hp,org_hp_regen,o rg_mp,org_mp_regen,str,int,dex,wit,con,men,base_at tack_type,base_attack_range,base_damage_range,base _rand_dam,base_physical_attack,base_critical,physi cal_hit_modify,base_attack_speed,base_reuse_delay, base_magic_attack,base_defend,base_magic_defend,ph ysical_avoid_modify,item_make_list,corpse_make_lis t,additional_make_list,additional_make_multi_list, hp_increase,mp_increase");
$exclude["npc"] = explode(",","");
$bad_type["npc"] = explode(",","");
$bad_type["item"] = explode(",","");
$include["item"] = explode(",","item_type,slot_bit_type,armor_type,etcitem_type,co nsume_type,default_action,weight,soulshot_count,sp iritshot_count,default_price,item_skill,critical_a ttack_skill,material_type,crystal_type,crystal_cou nt,is_trade,is_drop,is_destruct,physical_damage,ra ndom_damage,weapon_type,can_penetrate,critical,hit _modify,avoid_modify,dual_fhit_rate,shield_defense ,shield_defense_rate,attack_range,damage_range,att ack_speed,reuse_delay,mp_consume,magical_damage,du rability,damaged,physical_defense,magical_defense, mp_bonus,category,enchanted,equip_pet,magic_weapon ,,,,,");
//$exclude["item"] = explode(",","recipe_id,reduced_soulshot,reduced_spiritshot,redu ced_mp_consume,attack_skill,magic_skill,item_skill _enchanted_four,html,enchant_enable,,,,");
$exlude["item"] = explode(",","");
//Structure: <file type>_begin <type> <id> <name> <params> <file type>_end
$ftype = "item";
$fname = $ftype."data.txt";
$f = fopen($off_dir."\\".$fname,"r");
while (!feof($f)) {
$s = fgets($f);
if (preg_match("/".$ftype."_begin\s+(\w+)\s+(\d+)\s+\[([\w_\'\`\.\-0-9]+)\]\s+(.+)\s+".$ftype."_end/i",$s,$m)) {
$type = $m[1];
$id = $m[2];
$name = $m[3];
$params = $m[4];
preg_match_all("/([^\s]+)\s+/i",$params,$p);
$p = $p[1];
$params = array();
foreach ($p as $val) {
$p1 = explode("=",$val,2);
$params[$p1[0]] = $p1[1];
}
$data[$id]->type = $type;
$data[$id]->name = $name;
$data[$id]->params = $params;
}
}
fclose($f);
$fn = fopen($out_dir."\\".$fname,"w");
$f = fopen($orig_dir."\\".$fname,"r");
while (!feof($f)) {
$s = fgets($f);
if (preg_match("/".$ftype."_begin\s+(\w+)\s+(\d+)\s+\[([\w_\'\`\.\-0-9]+)\]\s+(.+)\s+".$ftype."_end/i",$s,$m)) {
$type = $m[1];
$id = $m[2];
$name = $m[3];
$params = $m[4];
preg_match_all("/\s?([^\s]+)\s?/i",$params,$p);
$p = $p[1];
$params = "";
foreach ($p as $val) {
$pp = explode("=",$val,2);
$p1 = $pp[0];
$p2 = $pp[1];
if (in_array($p1,$include) && $data[$id]->params[$p1]) $params[]=$p1."=".$data[$id]->params[$p1];
else $params[]=$p1."=".$p2;
//if (in_array($p1,$include[$ftype]) || !in_array($p1,$exclude[$ftype]))
//$params[]=$p1."=".($data[$id]->params[$p1]?$data[$id]->params[$p1]:$p2);
//else $params[]=$p1."=".$p2;
}
$name = $data[$id]->name;
$type = $data[$id]->type;
if (!in_array($type,$bad_type[$ftype])) $s = $ftype."_begin\t".$type."\t".$id."\t[".$name."]\t".implode("\t",$params)."\t".$ftype."_end\r\n";
}
fputs($fn,$s);
}
fclose($f);
fclose($fn);
?>
</pre>
[/php:1:0b4601f89b]
Thnx for all who test this conveter
:)
[php:1:0b4601f89b]<pre>
<?php
// Xelat Copyright(c) 2006
//[email protected]
//ICQ 195187980
$orig_dir = "c4\\orig";
$off_dir = "c4\\off";
$out_dir = "c4";
$include["npc"] = explode(",","level,acquire_exp_rate,exp,acquire_sp,clan,ignore_ clan_list,clan_help_range,slot_chest,slot_rhand,sl ot_lhand,skill_list,npc_ai,category,race,sex,undyi ng,can_be_attacked,corpse_time,no_sleep_mode,agro_ range,ground_high,ground_low,org_hp,org_hp_regen,o rg_mp,org_mp_regen,str,int,dex,wit,con,men,base_at tack_type,base_attack_range,base_damage_range,base _rand_dam,base_physical_attack,base_critical,physi cal_hit_modify,base_attack_speed,base_reuse_delay, base_magic_attack,base_defend,base_magic_defend,ph ysical_avoid_modify,item_make_list,corpse_make_lis t,additional_make_list,additional_make_multi_list, hp_increase,mp_increase");
$exclude["npc"] = explode(",","");
$bad_type["npc"] = explode(",","");
$bad_type["item"] = explode(",","");
$include["item"] = explode(",","item_type,slot_bit_type,armor_type,etcitem_type,co nsume_type,default_action,weight,soulshot_count,sp iritshot_count,default_price,item_skill,critical_a ttack_skill,material_type,crystal_type,crystal_cou nt,is_trade,is_drop,is_destruct,physical_damage,ra ndom_damage,weapon_type,can_penetrate,critical,hit _modify,avoid_modify,dual_fhit_rate,shield_defense ,shield_defense_rate,attack_range,damage_range,att ack_speed,reuse_delay,mp_consume,magical_damage,du rability,damaged,physical_defense,magical_defense, mp_bonus,category,enchanted,equip_pet,magic_weapon ,,,,,");
//$exclude["item"] = explode(",","recipe_id,reduced_soulshot,reduced_spiritshot,redu ced_mp_consume,attack_skill,magic_skill,item_skill _enchanted_four,html,enchant_enable,,,,");
$exlude["item"] = explode(",","");
//Structure: <file type>_begin <type> <id> <name> <params> <file type>_end
$ftype = "item";
$fname = $ftype."data.txt";
$f = fopen($off_dir."\\".$fname,"r");
while (!feof($f)) {
$s = fgets($f);
if (preg_match("/".$ftype."_begin\s+(\w+)\s+(\d+)\s+\[([\w_\'\`\.\-0-9]+)\]\s+(.+)\s+".$ftype."_end/i",$s,$m)) {
$type = $m[1];
$id = $m[2];
$name = $m[3];
$params = $m[4];
preg_match_all("/([^\s]+)\s+/i",$params,$p);
$p = $p[1];
$params = array();
foreach ($p as $val) {
$p1 = explode("=",$val,2);
$params[$p1[0]] = $p1[1];
}
$data[$id]->type = $type;
$data[$id]->name = $name;
$data[$id]->params = $params;
}
}
fclose($f);
$fn = fopen($out_dir."\\".$fname,"w");
$f = fopen($orig_dir."\\".$fname,"r");
while (!feof($f)) {
$s = fgets($f);
if (preg_match("/".$ftype."_begin\s+(\w+)\s+(\d+)\s+\[([\w_\'\`\.\-0-9]+)\]\s+(.+)\s+".$ftype."_end/i",$s,$m)) {
$type = $m[1];
$id = $m[2];
$name = $m[3];
$params = $m[4];
preg_match_all("/\s?([^\s]+)\s?/i",$params,$p);
$p = $p[1];
$params = "";
foreach ($p as $val) {
$pp = explode("=",$val,2);
$p1 = $pp[0];
$p2 = $pp[1];
if (in_array($p1,$include) && $data[$id]->params[$p1]) $params[]=$p1."=".$data[$id]->params[$p1];
else $params[]=$p1."=".$p2;
//if (in_array($p1,$include[$ftype]) || !in_array($p1,$exclude[$ftype]))
//$params[]=$p1."=".($data[$id]->params[$p1]?$data[$id]->params[$p1]:$p2);
//else $params[]=$p1."=".$p2;
}
$name = $data[$id]->name;
$type = $data[$id]->type;
if (!in_array($type,$bad_type[$ftype])) $s = $ftype."_begin\t".$type."\t".$id."\t[".$name."]\t".implode("\t",$params)."\t".$ftype."_end\r\n";
}
fputs($fn,$s);
}
fclose($f);
fclose($fn);
?>
</pre>
[/php:1:0b4601f89b]
Thnx for all who test this conveter
:)