<?php
// если убили
$fchar[7]=""; $l_i[$loc][$from]["char"]=implode("|",$fchar);
addjournal($loc,"all",$tchar[0]." погиб",$to);
// труп
/*if($id==(substr($to,0,17)=="i.s.d.n.c.demogn.")){
unlink ("quest/quest.demon");
}*/
$id = "i.s.d.".$to.".".rand(5,99);
while(isset($l_i[$loc][$id])) $id = "i.s.d.".$to.".".rand(5,99);
$item="труп (".$tchar[0].")|";
if ($tcrim || substr($to,0,4)=="n.a." || (substr($loc,0,2)=="c." && substr($loc,3)!=".in")) $item.="1|"; else $item.="0|";
$item.=time()+$g_destroy."|";
if ((strpos($l_i[$loc][$to]["items"],"i.q.pjpt:")===false || substr($to,0,2)!="u.") && $loc!='') {
// предметы
if ($l_i[$loc][$to]["items"]) $item.=str_replace("|",",",$l_i[$loc][$to]["items"])."|"; else $item.="|";
$pjpt=0;
} else {$pjpt; addjournal($loc,"all",$tchar[0]." спасает свои вещи пером жар-птицы!",$to); addjournal($loc,$to,"Вы спасли свои вещи пером жар-птицы!"); {additem($loc,$to,"","i.q.pjpt",1);$item.="|";}}
// шкура и т.д.
if ($l_i[$loc][$to]["osvej"]) $item.=str_replace("|",",",$l_i[$loc][$to]["osvej"]);
$l_i[$loc][$id]=$item;
// убийца
if (substr($to,0,2)=="u." && substr($from,0,2)=="u." && $from!=$to && $tchar[7]!=$from && !$tcrim && (!$clan1 || ($clan1 && $clan1!=$clan)) && !$wife) {
$l_i[$loc][$from]["char"]=implode("|",$fchar);
docrim($loc,$from,"убийца");
$fchar=explode("|",$l_i[$loc][$from]["char"]);
}
// статус игрока
if (substr($to,0,2)=='u.') {
$st=explode("|",$l_i[$loc][$from]["st"]);
$st[1]++; // +1 игрок
$l_i[$loc][$from]["st"]=implode("|",$st);
if ($game["floc"]==$loc && $game["fid"]==$to) {addjournal($loc,"all",$tchar[0]." потерял знамя!",$to); $l_i[$loc]["i.flag"]="знамя войны|1|0"; $game["fid"]="";}
$l_i[$loc][$to]["equip"]="";
if(!$pjpt) $l_i[$loc][$to]["items"]="";
$tchar[7]="";
$tchar[8]=1;
if ($tchar[12]) {
include("npc/n.a.losh");
$tc=explode(":",$tchar[12]);
$tc1=explode("|",$npc["char"]);
$tc1[5]=time();
if($tc[1]<$tc1[1]) $tc1[1]=$tc[1];
if (isset($l_i[$loc][$to]["name"])) {$tc1[0].=" ".$l_i[$loc][$to]["name"]; $npc["name"]=$l_i[$loc][$to]["name"]; unset($l_i[$loc][$to]["name"]);}
$npc["char"]=implode("|",$tc1);
$npc["owner"]=$to."|".$to."|0|0|0";
$l_i[$loc]["n.a.losh.".rand(99,9999)]=$npc;
}
$tchar[12]="";
$l_i[$loc][$to]["char"]=implode("|",$tchar);
if (!$tcrim && $fcrim && substr($from,0,2)=="u." && $from!=$to) { //killedby
if ($twar[15]) {$tmp=explode(":",$twar[15]); $twar[15]=$from.":".$tmp[1];} else $twar[15]=$from.":";
$l_i[$loc][$to]["war"]=implode("|",$twar);
}
$st=explode("|",$l_i[$loc][$to]["st"]);
$st[2]++; // +1 монстр
$l_i[$loc][$to]["st"]=implode("|",$st);
calcparam($loc,$to);
// пересчитаем параметры
addjournal($loc,$to,"Вы погибли!");addexp($loc,$to,-15);
} else { // npc респавн
$st=explode("|",$l_i[$loc][$from]["st"]);
$st[0]++; // +1 монстр
$l_i[$loc][$from]["st"]=implode("|",$st);
if ($twar[15]) {
$resp=explode(":",$twar[15]);
if ($resp[3]) {
$tchar[1]=$tchar[2]; $tchar[3]=$tchar[4]; $tchar[7]=""; $tchar[12]="";
$l_i[$loc][$to]["char"]=implode("|",$tchar);
$l_i[$loc][$to]["id"]=$to;
$npc="";
include "npc/".$to;
$l_i[$loc][$to]["items"]=$npc["items"];
$l_i[$loc][$to]["equip"]=$npc["equip"];
$l_i[$loc][$to]["osvej"]=$npc["osvej"];
addtimer($resp[0],0,rand($resp[1],$resp[2]),$l_i[$loc][$to],0);
} else {if ($tchar[10]) $tt="|".$tchar[10]; else $tt=""; addtimer($resp[0],0,rand($resp[1],$resp[2]),$to."|".$resp[1].":".$resp[2].$tt,0);}
}
if ($l_i[$loc][$from]["kvest"]) {
$kvest=explode("|",$l_i[$loc][$from]["kvest"]);
if (strpos($to,$kvest[0])!==false && rand(0,100)<=$kvest[3] && additem($loc,$from,"",$kvest[1],"count")<$kvest[2]) additem($loc,"",$from,$kvest[1],1);
}
// удаляем npc
unset($l_i[$loc][$to]);
}
// призрака не преследует
$fchar[7]="";
$l_i[$loc][$from]["char"]=implode("|",$fchar);
// экспа и уровень
if (substr($from,0,2)=='u.') {
if (substr($to,0,2)=='u.') {
$fwarr=explode("|",$l_i[$loc][$from]["war"]);
$fwarr[16]=$to;
if (!$fcrim && $tcrim && substr($to,0,2)=="u." && $from!=$to) { //killedto
if ($fwarr[15]) {$tmp=explode(":",$fwarr[15]); $fwarr[15]=$tmp[0].":".$to;} else $fwarr[15]=":".$to;
}
$l_i[$loc][$from]["war"]=implode("|",$fwarr);
}
if (substr($to,0,2)!="u.") { //killedto
$skills=split("\|",$l_i[$loc][$from]["skills"]);
$skills[3]+=$twar[13];
addjournal($loc,$from,"Опыт+ ".intval($twar[13]));
if ($skills[3]>$fwar[13]*$g_exp) {$skills[3]=0; $skills[22]+=1;addjournal($loc,$from,"уровень вверх!");}
$l_i[$loc][$from]["skills"]=implode("|",$skills);
if ($skills[3]==0) calcparam($loc,$from); //levelup
}
} else {
if (substr($from,0,4)=='n.s.' || substr($from,0,4)=='n.z.' || substr($from,0,4)=='n.a.') {
if (substr($to,0,2)=='u.') {
$fwarr=explode('|',$l_i[$loc][$from]['war']);
$fwarr[16]=$to;
if (!$fcrim && $tcrim && substr($to,0,2)=='u.' && $from!=$to) { //killedto
if ($fwarr[15]) {$tmp=explode(':',$fwarr[15]); $fwarr[15]=$tmp[0].':'.$to;} else $fwarr[15]=':'.$to;
}
$l_i[$loc][$from]['war']=implode('|',$fwarr);
}
if (substr($to,0,2)!='u.') { //killedto
$us=split('\|',$l_i[$loc][$from]['owner']);
$usr=$us[1];
$sk=split('\|',$l_i[$loc][$usr]['skills']);
$fw=split('\|',$l_i[$loc][$usr]['war']);
$exp=$twar[13]/2;
$sk[3]+=$exp;
addjournal($loc,$usr,'Onыт+ '.intval($exp));
if ($sk[3]>$fw[13]*$g_exp) {$sk[3]=0; $sk[4]+=1; $skills[34]+=1; addjournal($loc,$usr,'уровень вверх!');}
$l_i[$loc][$usr]['skills']=implode('|',$sk);
if ($sk[3]==0) calcparam($loc,$usr); //levelup
}
}
}