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

Comparing deliantra/Deliantra/Deliantra.pm (file contents):
Revision 1.80 by root, Tue Feb 6 22:08:14 2007 UTC vs.
Revision 1.84 by root, Wed Feb 7 00:22:34 2007 UTC

199 while (my ($k, $v) = each %attack_mask) { 199 while (my ($k, $v) = each %attack_mask) {
200 $ob->{"resist_$k"} = min 100, max -100, $ob->{"resist_$k"} + $value if $mask & $v; 200 $ob->{"resist_$k"} = min 100, max -100, $ob->{"resist_$k"} + $value if $mask & $v;
201 } 201 }
202} 202}
203 203
204my %MATERIAL = reverse
205 paper => 1,
206 iron => 2,
207 glass => 4,
208 leather => 8,
209 wood => 16,
210 organic => 32,
211 stone => 64,
212 cloth => 128,
213 adamant => 256,
214 liquid => 512,
215 tin => 1024,
216 bone => 2048,
217 ice => 4096,
218
219 # guesses
220 runestone => 12,
221 bronze => 18,
222 "ancient wood" => 20,
223 glass => 36,
224 marble => 66,
225 ice => 68,
226 stone => 70,
227 stone => 80,
228 cloth => 136,
229 ironwood => 144,
230 glacium => 260,
231 blood => 544,
232;
233
204# object as in "Object xxx", i.e. archetypes 234# object as in "Object xxx", i.e. archetypes
205sub normalize_object($) { 235sub normalize_object($) {
206 my ($ob) = @_; 236 my ($ob) = @_;
237
238 # convert material bitset to materialname, if possible
239 if (exists $ob->{material}) {
240 if (!$ob->{material}) {
241 delete $ob->{material};
242 } elsif (exists $ob->{materialname}) {
243 if ($MATERIAL{$ob->{material}} eq $ob->{materialname}) {
244 delete $ob->{material};
245 } else {
246 warn "object $ob->{_name} has both materialname ($ob->{materialname}) and material ($ob->{material}) set.\n";
247 delete $ob->{material}; # assume materilname is more specific and nuke material
248 }
249 } elsif (my $name = $MATERIAL{$ob->{material}}) {
250 delete $ob->{material};
251 $ob->{materialname} = $name;
252 } else {
253 warn "object $ob->{_name} has unknown material ($ob->{material}) set.\n";
254 }
255 }
207 256
208 # nuke outdated or never supported fields 257 # nuke outdated or never supported fields
209 delete @$ob{qw( 258 delete @$ob{qw(
210 can_knockback can_parry can_impale can_cut can_dam_armour 259 can_knockback can_parry can_impale can_cut can_dam_armour
211 can_apply pass_thru can_pass_thru 260 can_apply pass_thru can_pass_thru
421 push @{ $arc{anim} }, $_; 470 push @{ $arc{anim} }, $_;
422 } 471 }
423 } elsif (/^(\S+)\s*(.*)$/) { 472 } elsif (/^(\S+)\s*(.*)$/) {
424 $arc{lc $1} = $2; 473 $arc{lc $1} = $2;
425 } elsif (/^\s*#/) { 474 } elsif (/^\s*#/) {
426 $arc{_comment} .= $_; 475 $arc{_comment} .= "$_\n";
427 476
428 } elsif (/^\s*$/) { 477 } elsif (/^\s*$/) {
429 # 478 #
430 } else { 479 } else {
431 warn "$path: unparsable line '$_' in arch $arc{_name}"; 480 warn "$path: unparsable line '$_' in arch $arc{_name}";
437 486
438 while (<$fh>) { 487 while (<$fh>) {
439 s/\s+$//; 488 s/\s+$//;
440 if (/^more$/i) { 489 if (/^more$/i) {
441 $more = $prev; 490 $more = $prev;
442 } elsif (/^\s*#/) {
443 $comment .= $_;
444 } elsif (/^object (\S+)$/i) { 491 } elsif (/^object (\S+)$/i) {
445 my $name = $1; 492 my $name = $1;
446 my $arc = attr_thaw normalize_object $parse_block->(_name => $name, _comment => $comment); 493 my $arc = attr_thaw normalize_object $parse_block->(_name => $name, _comment => $comment);
494 undef $comment;
447 delete $arc{_comment} unless length $arc{_comment}; 495 delete $arc{_comment} unless length $arc{_comment};
448 $arc->{_atype} = 'object'; 496 $arc->{_atype} = 'object';
449 497
450 if ($more) { 498 if ($more) {
451 $more->{more} = $arc; 499 $more->{more} = $arc;
455 $prev = $arc; 503 $prev = $arc;
456 $more = undef; 504 $more = undef;
457 } elsif (/^arch (\S+)$/i) { 505 } elsif (/^arch (\S+)$/i) {
458 my $name = $1; 506 my $name = $1;
459 my $arc = attr_thaw normalize_arch $parse_block->(_name => $name, _comment => $comment); 507 my $arc = attr_thaw normalize_arch $parse_block->(_name => $name, _comment => $comment);
508 undef $comment;
460 delete $arc{_comment} unless length $arc{_comment}; 509 delete $arc{_comment} unless length $arc{_comment};
461 $arc->{_atype} = 'arch'; 510 $arc->{_atype} = 'arch';
462 511
463 if ($more) { 512 if ($more) {
464 $more->{more} = $arc; 513 $more->{more} = $arc;
474 push @{$toplevel->{lev_array}}, $_+0; 523 push @{$toplevel->{lev_array}}, $_+0;
475 } 524 }
476 } else { 525 } else {
477 $toplevel->{$1} = $2; 526 $toplevel->{$1} = $2;
478 } 527 }
528 } elsif (/^\s*#/) {
529 $comment .= "$_\n";
479 } elsif (/^\s*($|#)/) { 530 } elsif (/^\s*($|#)/) {
480 # 531 #
481 } else { 532 } else {
482 die "$path: unparseable top-level line '$_'"; 533 die "$path: unparseable top-level line '$_'";
483 } 534 }
503 if (exists $a{attack_movement_bits_0_3} or exists $a{attack_movement_bits_4_7}) { 554 if (exists $a{attack_movement_bits_0_3} or exists $a{attack_movement_bits_4_7}) {
504 $a{attack_movement} = (delete $a{attack_movement_bits_0_3}) 555 $a{attack_movement} = (delete $a{attack_movement_bits_0_3})
505 | (delete $a{attack_movement_bits_4_7}); 556 | (delete $a{attack_movement_bits_4_7});
506 } 557 }
507 558
559 if (my $comment = delete $a{_comment}) {
560 if ($comment =~ /[^\n\s#]/) {
561 $str .= $comment;
562 }
563 }
564
508 $str .= ((exists $a{_atype}) ? $a{_atype} : 'arch'). " $a{_name}\n"; 565 $str .= ((exists $a{_atype}) ? $a{_atype} : 'arch'). " $a{_name}\n";
509 566
510 my $inv = delete $a{inventory}; 567 my $inv = delete $a{inventory};
511 my $more = delete $a{more}; # arches do not support 'more', but old maps can contain some 568 my $more = delete $a{more}; # arches do not support 'more', but old maps can contain some
512 my $anim = delete $a{anim}; 569 my $anim = delete $a{anim};
513 570
514 my @kv; 571 my @kv;
515 572
571 if $anim; 628 if $anim;
572 } 629 }
573 630
574 $str .= "end\n"; 631 $str .= "end\n";
575 632
576 if (($a{_atype} eq 'object') && $more) { 633 if ($a{_atype} eq 'object') {
634 if ($more) {
577 $str .= "\nmore\n"; 635 $str .= "more\n";
578 $append->($more) if $more; 636 $append->($more) if $more;
637 } else {
638 $str .= "\n";
639 }
579 } 640 }
580 }; 641 };
581 642
582 for (@$arch) { 643 for (@$arch) {
583 $append->($_); 644 $append->($_);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines