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.28 by root, Sat Dec 13 20:34:37 2008 UTC vs.
Revision 1.32 by elmex, Tue Apr 27 17:08:09 2010 UTC

8 8
9=cut 9=cut
10 10
11package Jeweler; 11package Jeweler;
12 12
13use strict; 13use common::sense;
14use YAML;
15 14
16=over 4 15=over 4
17 16
18=item @RESISTS 17=item @RESISTS
19 18
186 unless $found; 185 unless $found;
187} 186}
188 187
189# this function converts metals/minerals into a raw ring (of adornment) 188# this function converts metals/minerals into a raw ring (of adornment)
190sub simple_converter { 189sub simple_converter {
191 my ($pl, $ingred, $chdl, $conv) = @_; 190 my ($pl, $ingred, $chdl, $conv, $sk_lvl, $low_skill_cb) = @_;
192 191
193 $conv = lc $conv; 192 $conv = lc $conv;
194 my $cnvs = $CFG->{conversions}; 193 my $cnvs = $CFG->{conversions};
195 194
196 return unless $cnvs->{$conv}; 195 return unless $cnvs->{$conv};
218 217
219 unless ($outarchvalfact >= 1) { 218 unless ($outarchvalfact >= 1) {
220 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";
221 } 220 }
222 221
223 my $archvalsum = $ingred->value ($ingr_grp, $srcarchname); 222 my $archvalsum = $ingred->value ($ingr_grp, $srcarchname);
224 $ingred->remove ($ingr_grp, $srcarchname);
225
226 my $outarchval = cf::arch::find ($outarch)->value; 223 my $outarchval = cf::arch::find ($outarch)->value;
227
228 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
229 if ($nrof) { 232 if ($nrof) {
230 # 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);
231 for (1 .. $nrof) { 235 for (1 .. $nrof) {
232 $chdl->put (my $ob = cf::object::new $outarch); 236 $chdl->put (my $ob = cf::object::new $outarch);
233 $ob->set_animation (cf::rndm $ob->num_animations) 237 $ob->set_animation (cf::rndm $ob->num_animations)
234 if ($ob->type == cf::RING); 238 if ($ob->type == cf::RING);
235 $ob->flag (cf::FLAG_IDENTIFIED, 1); 239 $ob->flag (cf::FLAG_IDENTIFIED, 1);
841 $obj->{arch} = $thing->arch->archname; 845 $obj->{arch} = $thing->arch->archname;
842 $obj->{face} = $thing->face; 846 $obj->{face} = $thing->face;
843 847
844 $obj->{value} = $thing->value; 848 $obj->{value} = $thing->value;
845 849
850 $obj->{is_ring} = ($thing->type == cf::RING);
851
846 $self->{hash} = $obj 852 $self->{hash} = $obj
847} 853}
848 854
849sub to_object { 855sub to_object {
850 my ($self) = @_; 856 my ($self) = @_;
912sub resist_level { 918sub resist_level {
913 my ($self) = @_; 919 my ($self) = @_;
914 920
915 my $resists = $self->{hash}->{resist} || {}; 921 my $resists = $self->{hash}->{resist} || {};
916 922
917 my $att_res_lvl = Jeweler::getcfg (maxlevels => 'resist_level'); 923 my $att_res_lvl = Jeweler::getcfg (maxlevels => 'resist_level');
918 my $efc_res_lvl = Jeweler::getcfg (maxlevels => 'effect_resist_level'); 924 my $efc_res_lvl = Jeweler::getcfg (maxlevels => 'effect_resist_level');
919 my $max_att_res = Jeweler::getcfg (maximprovements => 'attack_resistances'); 925 my $max_att_res = Jeweler::getcfg (maximprovements => 'attack_resistances');
920 my $max_efc_res = Jeweler::getcfg (maximprovements => 'effect_resistances'); 926 my $max_efc_res = Jeweler::getcfg (maximprovements => 'effect_resistances');
921 my $max_ovr_res = Jeweler::getcfg (maximprovements => 'resistances'); 927 my $max_ovr_res = Jeweler::getcfg (maximprovements => 'resistances');
922 928
923 my $ressum = 0; 929 my $ressum = 0;
983sub power_to_level { 989sub power_to_level {
984 my ($self, $lvldescr) = @_; 990 my ($self, $lvldescr) = @_;
985 991
986 my $max_imprs = Jeweler::getcfg (maximprovements => 'improvements'); 992 my $max_imprs = Jeweler::getcfg (maximprovements => 'improvements');
987 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');
988 995
989 my ($stat_lvl, $stat_imprs) = $self->stat_level; 996 my ($stat_lvl, $stat_imprs) = $self->stat_level;
990 my ($resist_lvl, $res_imprs) = $self->resist_level; 997 my ($resist_lvl, $res_imprs) = $self->resist_level;
991 my ($spec_lvl, $spec_imprs) = $self->special_level; 998 my ($spec_lvl, $spec_imprs) = $self->special_level;
992 999
993 my $impr_sum = $stat_imprs + $res_imprs + $spec_imprs; 1000 my $impr_sum = $stat_imprs + $res_imprs + $spec_imprs;
994 1001
995 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
996 1005
997 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);
998 1013
999 if ($lvldescr) { 1014 if ($lvldescr) {
1000 $$lvldescr = 1015 $$lvldescr =
1001 sprintf "%3d: %s\n", $levl, 1016 sprintf "%3d: %s\n", $levl,
1002 "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