resolve(bonus, target, god,arg) {
   object ob,obje;
   int effect, exp,i,i2,modifier, worth;
   string totals, tmp;

   if (!target) { write("Reincarnate whom?\n"); return; }
   ob = find_player(lower_case(target));
   if (!ob) { write("No such a player.\n"); return 1; }
   if (!ob->query_dead() && !arg) {
	write(capitalize(target) + " is not dead.\n");
	return 1;
   }
   if (ob->query_free_exp() != "0" && ob->query_free_exp() != 0) {
	write(capitalize(ob->query_real_name())+" has free experience, he"+
		"can't be reincarnated.\n");
	return 1;
   }
   write("You reincarnate " + capitalize(target) + ".\n");
   tell_object(ob, this_player()->query_name()+" reincarnated you.\n");
   effect = 10 - this_player()->query_skill("cast reincarnation")/20;
   if (effect < 5) {
        effect = 5;
   }
   if (effect > 10) {
	effect = 10;
   }
   if(arg) effect = 15;
   log_file("REINC_LOG", capitalize(target)+" reinced by "+
		this_player()->query_name()+" ("+effect+") ");

   modifier = 0;

   tmp = ob->query_total_string();

   log_file("REINC_LOG", "Worth: "+tmp+"\n");
   tell_object(ob, "Totals: "+tmp+"\n");

   if (strlen(tmp) > 10) {
	exp = 100000000;
	i = 1000000000;
	tmp = 0;
   }

   if (tmp && strlen(tmp) > 9) {
     modifier = strlen(tmp) - 9;
     tmp = extract(tmp, 0, 8);
     if (this_player()->query_tester()) write("Tmp:"+tmp+" modifier:"+modifier+"\n");
   }
   if (tmp) sscanf(tmp, "%d", worth);
   if (!exp) exp = worth / 300;
   if (!i) i = (worth / 100) * effect;
   if (modifier) { exp = exp * 10^modifier; }
   if (modifier) { i = i * 10^modifier; }
   if(!arg) write("You see "+capitalize(ob->query_real_name())+"'s life flashing in"+
	" front of you eyes and catch a part of his experiences.\n");
   if(!arg) write("You receive "+exp+" experince points.\n");
   tell_object(ob, "You feel drained.\n");
   tell_object(ob, "You lost "+i+" experience points in the reincarnation.\n");
   ob->reduce_total_worth(i);

   if (exp > 1000000) {
	exp = 1000000 + (exp - 1000000)/10;
   }
   if (exp > 5000000) {
	exp = 5000000;
   }

   i2 = 0;
   obje = all_inventory(ob);
   while(i2<sizeof(obje)) {
      if(obje[i2] && obje[i2]->short()) { destruct(obje[i2]); }
      i2 += 1;
   }
   if(!arg) { 
     log_file("REINC_LOG", this_player()->query_name()+" got "+
	exp+" exp for reincing "+ob->query_name()+" (cost:"+i+"), "+
	modifier+".\n");
     this_player()->add_party_exp(exp);
   }
   ob->remove_ghost(100, "/obj/race_selection");
   ob->reinc();
}

