ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/reseller.ext
(Generate patch)

Comparing deliantra/maps/perl/reseller.ext (file contents):
Revision 1.3 by elmex, Mon Aug 14 21:39:00 2006 UTC vs.
Revision 1.7 by elmex, Tue Aug 15 16:51:59 2006 UTC

134 $who->message ("The shopkeeper says: Sorry, you can't sell money here.", cf::NDI_BROWN); 134 $who->message ("The shopkeeper says: Sorry, you can't sell money here.", cf::NDI_BROWN);
135 $what->insert_ob_in_ob ($who); 135 $what->insert_ob_in_ob ($who);
136 return 1; 136 return 1;
137 } 137 }
138 138
139 unless ($what->get_flag (cf::FLAG_IDENTIFIED)) { 139 if (!$what->get_flag (cf::FLAG_IDENTIFIED) && $what->need_identify) {
140 $who->message ("The shopkeeper says: Sorry, you can't sell unidentified stuff here.", cf::NDI_BROWN); 140 $who->message ("The shopkeeper says: Sorry, you can't sell unidentified stuff here.", cf::NDI_BROWN);
141 $what->insert_ob_in_ob ($who); 141 $what->insert_ob_in_ob ($who);
142 return 1; 142 return 1;
143 } 143 }
144 144
145 my $orig_value = $what->value; 145 my $orig_value = $what->value;
146 my $value = 0; 146 my $value = 0;
147 147
148 if ($name =~ m/\S/) { 148 if ($name =~ m/\S/) {
149 unless ($name =~ m/\d+\s*\S+/) { 149 unless ($name =~ m/\d+\s*\S+/) {
150 $who->message ("The shopkeeper says: Sorry, i don't recognize '$name' as currency. Please name your item like '10 royalty' or '10 platinum 2 silver'", cf::NDI_BROWN); 150 $who->message ("The shopkeeper says: Sorry, I don't recognize '$name' as currency. Please name your item like '10 royalty' or '10 platinum 2 silver'", cf::NDI_BROWN);
151 $what->insert_ob_in_ob ($who); 151 $what->insert_ob_in_ob ($who);
152 return 1; 152 return 1;
153 } 153 }
154 154
155 while ($name =~ s/^\s*(\d+)\s*(\S+)//) { 155 while ($name =~ s/^\s*(\d+)\s*(\S+)//) {
163 } 163 }
164 } else { 164 } else {
165 $value = $what->query_cost ($who, cf::F_SELL | cf::F_SHOP) / ($what->nrof || 1); 165 $value = $what->query_cost ($who, cf::F_SELL | cf::F_SHOP) / ($what->nrof || 1);
166 } 166 }
167 167
168 if ($value < 0) {
169 $what->insert_ob_in_ob ($who);
170 $who->message ("The shopkeeper says: You can't sell something for a negative value: $value", cf::NDI_BROWN);
171 return 1;
172 }
173
168 my $fee = $value / 100; # 1% selling fee 174 my $fee = $value / 100; # 1% selling fee
169 175
170 unless ($who->pay_amount ($fee)) { 176 unless ($who->pay_amount ($fee)) {
171 $who->message ( 177 $who->message (
172 "The shopkeeper says: You need " . cf::cost_string_from_value ($fee) . " to pay the 1% fee for this item", 178 "The shopkeeper says: You need " . cf::cost_string_from_value ($fee) . " to pay the 1% fee for this item",
205 211
206 $what->set_ob_key_value (ext_reseller_seller => $who->name); 212 $what->set_ob_key_value (ext_reseller_seller => $who->name);
207 $what->set_ob_key_value (ext_reseller_orig_value => $orig_value); 213 $what->set_ob_key_value (ext_reseller_orig_value => $orig_value);
208# warn "SET SELLER ON " . $what->name . " + " . $what->{seller}->[0] . "\n"; 214# warn "SET SELLER ON " . $what->name . " + " . $what->{seller}->[0] . "\n";
209 $what->set_custom_name ( 215 $what->set_custom_name (
210 $what->name . " (property of " . $who->name . ")" 216 $what->name . " (by " . $who->name . ")"
211 ); 217 );
212 $what->set_flag (cf::FLAG_UNPAID, 1); 218 $what->set_flag (cf::FLAG_UNPAID, 1);
213 $what->insert_ob_in_map_at ($who->map, $who, cf::INS_BELOW_ORIGINATOR, $who->x, $who->y); 219 $what->insert_ob_in_map_at ($who->map, $who, cf::INS_BELOW_ORIGINATOR, $who->x, $who->y);
214 1; 220 1;
215} 221}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines