Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 14.07.2006, 20:08   #1
Xari0n
Архивный участник
 
Join Date: Jul 2006
Posts: 119
Default [SHARE] Converter for c4 retail itemdata-npcdata to c1

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,slot_lhand,skill_list,npc_ai,category,r ace,sex,undying,can_be_attacked,corpse_time,no_sle ep_mode,agro_range,ground_high,ground_low,org_hp,o rg_hp_regen,org_mp,org_mp_regen,str,int,dex,wit,co n,men,base_attack_type,base_attack_range,base_dama ge_range,base_rand_dam,base_physical_attack,base_c ritical,physical_hit_modify,base_attack_speed,base _reuse_delay,base_magic_attack,base_defend,base_ma gic_defend,physical_avoid_modify,item_make_list,co rpse_make_list,additional_make_list,additional_mak e_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,et citem_type,consume_type,default_action,weight,soul shot_count,spiritshot_count,default_price,item_ski ll,critical_attack_skill,material_type,crystal_typ e,crystal_count,is_trade,is_drop,is_destruct,physi cal_damage,random_damage,weapon_type,can_penetrate ,critical,hit_modify,avoid_modify,dual_fhit_rate,s hield_defense,shield_defense_rate,attack_range,dam age_range,attack_speed,reuse_delay,mp_consume,magi cal_damage,durability,damaged,physical_defense,mag ical_defense,mp_bonus,category,enchanted,equip_pet ,magic_weapon,,,,,");
//$exclude["item"] = explode(",","recipe_id,reduced_soulshot,reduced_sp iritshot,reduced_mp_consume,attack_skill,magic_ski ll,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
Xari0n 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 15:44.