ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/Jeweler.pm
(Generate patch)

Comparing deliantra/server/ext/Jeweler.pm (file contents):
Revision 1.29 by root, Mon Oct 12 14:00:58 2009 UTC vs.
Revision 1.32 by elmex, Tue Apr 27 17:08:09 2010 UTC

185 unless $found; 185 unless $found;
186} 186}
187 187
188# this function converts metals/minerals into a raw ring (of adornment) 188# this function converts metals/minerals into a raw ring (of adornment)
189sub simple_converter { 189sub simple_converter {
190 my ($pl, $ingred, $chdl, $conv) = @_; 190 my ($pl, $ingred, $chdl, $conv, $sk_lvl, $low_skill_cb) = @_;
191 191
192 $conv = lc $conv; 192 $conv = lc $conv;
193 my $cnvs = $CFG->{conversions}; 193 my $cnvs = $CFG->{conversions};
194 194
195 return unless $cnvs->{$conv}; 195 return unless $cnvs->{$conv};
217 217
218 unless ($outarchvalfact >= 1) { 218 unless ($outarchvalfact >= 1) {
219 warn "WARNING: source-arch-value-multiplier < 1 in conversion '$outarch', results in more valuable output!\n"; 219 warn "WARNING: source-arch-value-multiplier < 1 in conversion '$outarch', results in more valuable output!\n";
220 } 220 }
221 221
222 my $archvalsum = $ingred->value ($ingr_grp, $srcarchname); 222 my $archvalsum = $ingred->value ($ingr_grp, $srcarchname);
223 $ingred->remove ($ingr_grp, $srcarchname);
224
225 my $outarchval = cf::arch::find ($outarch)->value; 223 my $outarchval = cf::arch::find ($outarch)->value;
226
227 my $nrof = int $archvalsum / (($outarchval || 1000) * $outarchvalfact); 224 my $nrof = int $archvalsum / (($outarchval || 1000) * $outarchvalfact);
225 my $can_make_nr = int (($sk_lvl / 2) + 10);
226
227 if ($nrof > $can_make_nr) {
228 $pl->ob->message ("Your jeweler level is too low to make $nrof rings, you can only make $can_make_nr at your current level.");
229 return;
230 }
231
228 if ($nrof) { 232 if ($nrof) {
229 # XXX: yes, I know what I'm doing here, I don't set nrof, but it didn't work somehow (pls. check sometimes) 233 # XXX: yes, I know what I'm doing here, I don't set nrof, but it didn't work somehow (pls. check sometimes)
234 $ingred->remove ($ingr_grp, $srcarchname);
230 for (1 .. $nrof) { 235 for (1 .. $nrof) {
231 $chdl->put (my $ob = cf::object::new $outarch); 236 $chdl->put (my $ob = cf::object::new $outarch);
232 $ob->set_animation (cf::rndm $ob->num_animations) 237 $ob->set_animation (cf::rndm $ob->num_animations)
233 if ($ob->type == cf::RING); 238 if ($ob->type == cf::RING);
234 $ob->flag (cf::FLAG_IDENTIFIED, 1); 239 $ob->flag (cf::FLAG_IDENTIFIED, 1);
840 $obj->{arch} = $thing->arch->archname; 845 $obj->{arch} = $thing->arch->archname;
841 $obj->{face} = $thing->face; 846 $obj->{face} = $thing->face;
842 847
843 $obj->{value} = $thing->value; 848 $obj->{value} = $thing->value;
844 849
850 $obj->{is_ring} = ($thing->type == cf::RING);
851
845 $self->{hash} = $obj 852 $self->{hash} = $obj
846} 853}
847 854
848sub to_object { 855sub to_object {
849 my ($self) = @_; 856 my ($self) = @_;
911sub resist_level { 918sub resist_level {
912 my ($self) = @_; 919 my ($self) = @_;
913 920
914 my $resists = $self->{hash}->{resist} || {}; 921 my $resists = $self->{hash}->{resist} || {};
915 922
916 my $att_res_lvl = Jeweler::getcfg (maxlevels => 'resist_level'); 923 my $att_res_lvl = Jeweler::getcfg (maxlevels => 'resist_level');
917 my $efc_res_lvl = Jeweler::getcfg (maxlevels => 'effect_resist_level'); 924 my $efc_res_lvl = Jeweler::getcfg (maxlevels => 'effect_resist_level');
918 my $max_att_res = Jeweler::getcfg (maximprovements => 'attack_resistances'); 925 my $max_att_res = Jeweler::getcfg (maximprovements => 'attack_resistances');
919 my $max_efc_res = Jeweler::getcfg (maximprovements => 'effect_resistances'); 926 my $max_efc_res = Jeweler::getcfg (maximprovements => 'effect_resistances');
920 my $max_ovr_res = Jeweler::getcfg (maximprovements => 'resistances'); 927 my $max_ovr_res = Jeweler::getcfg (maximprovements => 'resistances');
921 928
922 my $ressum = 0; 929 my $ressum = 0;
982sub power_to_level { 989sub power_to_level {
983 my ($self, $lvldescr) = @_; 990 my ($self, $lvldescr) = @_;
984 991
985 my $max_imprs = Jeweler::getcfg (maximprovements => 'improvements'); 992 my $max_imprs = Jeweler::getcfg (maximprovements => 'improvements');
986 my $max_impr_lvl = Jeweler::getcfg (maxlevels => 'improve_level'); 993 my $max_impr_lvl = Jeweler::getcfg (maxlevels => 'improve_level');
994 my $ring_offs = Jeweler::getcfg (maxlevels => 'ring_offset');
987 995
988 my ($stat_lvl, $stat_imprs) = $self->stat_level; 996 my ($stat_lvl, $stat_imprs) = $self->stat_level;
989 my ($resist_lvl, $res_imprs) = $self->resist_level; 997 my ($resist_lvl, $res_imprs) = $self->resist_level;
990 my ($spec_lvl, $spec_imprs) = $self->special_level; 998 my ($spec_lvl, $spec_imprs) = $self->special_level;
991 999
992 my $impr_sum = $stat_imprs + $res_imprs + $spec_imprs; 1000 my $impr_sum = $stat_imprs + $res_imprs + $spec_imprs;
993 1001
994 my $impr_lvl = ceil (($max_impr_lvl / ($max_imprs + 1)) * ($impr_sum - 1)); # 1 improvemnt bonus 1002 my $impr_lvl =
1003 ceil (($max_impr_lvl / ($max_imprs + 1))
1004 * ($impr_sum - 1)); # 1 improvemnt bonus
995 1005
996 my $levl = int max ($stat_lvl, $resist_lvl, $impr_lvl, $spec_lvl, 0); 1006 my $levl = int max ($stat_lvl, $resist_lvl, $impr_lvl, $spec_lvl, 0);
1007
1008 if ($self->{hash}->{is_ring}) {
1009 $levl += $ring_offs;
1010 }
1011
1012 $levl = min ($levl, cf::settings->max_level);
997 1013
998 if ($lvldescr) { 1014 if ($lvldescr) {
999 $$lvldescr = 1015 $$lvldescr =
1000 sprintf "%3d: %s\n", $levl, 1016 sprintf "%3d: %s\n", $levl,
1001 "stat: $stat_lvl, resist: $resist_lvl, improve: $impr_lvl, " 1017 "stat: $stat_lvl, resist: $resist_lvl, improve: $impr_lvl, "

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines