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.8 by root, Fri Aug 25 15:07:43 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines