… | |
… | |
36 | our %FIELD_MULTILINE = ( |
36 | our %FIELD_MULTILINE = ( |
37 | msg => "endmsg", |
37 | msg => "endmsg", |
38 | lore => "endlore", |
38 | lore => "endlore", |
39 | maplore => "endmaplore", |
39 | maplore => "endmaplore", |
40 | ); |
40 | ); |
|
|
41 | |
|
|
42 | # movement bit type, PITA |
|
|
43 | our %FIELD_MOVEMENT = map +($_ => undef), |
|
|
44 | qw(move_type move_block move_allow move_on move_off move_slow); |
41 | |
45 | |
42 | # same as in server save routine, to (hopefully) be compatible |
46 | # same as in server save routine, to (hopefully) be compatible |
43 | # to the other editors. |
47 | # to the other editors. |
44 | our @FIELD_ORDER_MAP = (qw( |
48 | our @FIELD_ORDER_MAP = (qw( |
45 | name swap_time reset_timeout fixed_resettime difficulty region |
49 | name swap_time reset_timeout fixed_resettime difficulty region |
… | |
… | |
55 | |
59 | |
56 | name name_pl custom_name title race |
60 | name name_pl custom_name title race |
57 | slaying skill msg lore other_arch face |
61 | slaying skill msg lore other_arch face |
58 | #todo-events |
62 | #todo-events |
59 | animation is_animated |
63 | animation is_animated |
60 | Str Dex Con Wis Pow Cha Int |
64 | str dex con wis pow cha int |
61 | hp maxhp sp maxsp grace maxgrace |
65 | hp maxhp sp maxsp grace maxgrace |
62 | exp perm_exp expmul |
66 | exp perm_exp expmul |
63 | food dam luck wc ac x y speed speed_left move_state attack_movement |
67 | food dam luck wc ac x y speed speed_left move_state attack_movement |
64 | nrof level direction type subtype |
68 | nrof level direction type subtype attacktype |
65 | |
69 | |
66 | resist_physical resist_magic resist_fire resist_electricity |
70 | resist_physical resist_magic resist_fire resist_electricity |
67 | resist_cold resist_confusion resist_acid resist_drain |
71 | resist_cold resist_confusion resist_acid resist_drain |
68 | resist_weaponmagic resist_ghosthit resist_poison resist_slow |
72 | resist_weaponmagic resist_ghosthit resist_poison resist_slow |
69 | resist_paralyze resist_turn_undead resist_fear resist_cancellation |
73 | resist_paralyze resist_turn_undead resist_fear resist_cancellation |
… | |
… | |
104 | sub MOVE_FLY_LOW (){ 0x02 } |
108 | sub MOVE_FLY_LOW (){ 0x02 } |
105 | sub MOVE_FLY_HIGH (){ 0x04 } |
109 | sub MOVE_FLY_HIGH (){ 0x04 } |
106 | sub MOVE_FLYING (){ 0x06 } |
110 | sub MOVE_FLYING (){ 0x06 } |
107 | sub MOVE_SWIM (){ 0x08 } |
111 | sub MOVE_SWIM (){ 0x08 } |
108 | sub MOVE_BOAT (){ 0x10 } |
112 | sub MOVE_BOAT (){ 0x10 } |
|
|
113 | sub MOVE_KNOWN (){ 0x1f } # all of above |
109 | sub MOVE_ALL (){ 0xff } |
114 | sub MOVE_ALLBIT (){ 0x10000 } |
|
|
115 | sub MOVE_ALL (){ 0x1001f } # very special value, more PITA |
110 | |
116 | |
111 | sub load_ref($) { |
117 | sub load_ref($) { |
112 | my ($path) = @_; |
118 | my ($path) = @_; |
113 | |
119 | |
114 | open my $fh, "<", $path |
120 | open my $fh, "<", $path |
… | |
… | |
137 | delete $ob->{$_} for qw( |
143 | delete $ob->{$_} for qw( |
138 | can_knockback can_parry can_impale can_cut can_dam_armour |
144 | can_knockback can_parry can_impale can_cut can_dam_armour |
139 | can_apply pass_thru can_pass_thru |
145 | can_apply pass_thru can_pass_thru |
140 | ); |
146 | ); |
141 | |
147 | |
142 | for my $attr (qw(move_type move_block move_allow move_on move_off move_slow)) { |
148 | for my $attr (keys %FIELD_MOVEMENT) { |
143 | next unless exists $ob->{$attr}; |
149 | next unless exists $ob->{$attr}; |
|
|
150 | |
|
|
151 | $ob->{$attr} = MOVE_ALL if $ob->{$attr} == 255; #d# compatibility |
|
|
152 | |
144 | next if $ob->{$attr} =~ /^\d+$/; |
153 | next if $ob->{$attr} =~ /^\d+$/; |
145 | |
154 | |
146 | my $flags = 0; |
155 | my $flags = 0; |
147 | |
156 | |
148 | # assume list |
157 | # assume list |
… | |
… | |
422 | my $type = $obj->{type} || $arch->{type}; |
431 | my $type = $obj->{type} || $arch->{type}; |
423 | |
432 | |
424 | if ($type > 0) { |
433 | if ($type > 0) { |
425 | $root = $Crossfire::Data::ATTR{$type}; |
434 | $root = $Crossfire::Data::ATTR{$type}; |
426 | } else { |
435 | } else { |
|
|
436 | my %a = (%$arch, %$obj); |
|
|
437 | |
|
|
438 | if ($a{is_floor} && !$a{alive}) { |
|
|
439 | $root = $Crossfire::Data::TYPE{Floor}; |
|
|
440 | } elsif (!$a{is_floor} && $a{alive} && !$a{tear_down}) { |
|
|
441 | $root = $Crossfire::Data::TYPE{"Monster & NPC"}; |
|
|
442 | } elsif (!$a{is_floor} && !$a{alive} && $a{move_block}) { |
|
|
443 | $root = $Crossfire::Data::TYPE{Wall}; |
|
|
444 | } elsif (!$a{is_floor} && $a{alive} && $a{tear_down}) { |
|
|
445 | $root = $Crossfire::Data::TYPE{"Weak Wall"}; |
|
|
446 | } else { |
427 | $root = $Crossfire::Data::TYPE{Misc}; |
447 | $root = $Crossfire::Data::TYPE{Misc}; |
428 | |
|
|
429 | type: |
|
|
430 | for (@Crossfire::Data::ATTR0) { |
|
|
431 | my $req = $_->{required} |
|
|
432 | or die "internal error: ATTR0 without 'required'"; |
|
|
433 | |
|
|
434 | keys %$req; |
|
|
435 | while (my ($k, $v) = each %$req) { |
|
|
436 | next type |
|
|
437 | unless $obj->{$k} == $v || $arch->{$k} == $v; |
|
|
438 | } |
|
|
439 | |
|
|
440 | $root = $_; |
|
|
441 | } |
448 | } |
442 | } |
449 | } |
443 | |
450 | |
444 | my @import = ($root); |
451 | my @import = ($root); |
445 | |
452 | |
… | |
… | |
619 | cache_file "$LIB/crossfire.0", "$VARDIR/tilecache.pst", sub { |
626 | cache_file "$LIB/crossfire.0", "$VARDIR/tilecache.pst", sub { |
620 | $TILE = new_from_file Gtk2::Gdk::Pixbuf "$VARDIR/tilecache.png" |
627 | $TILE = new_from_file Gtk2::Gdk::Pixbuf "$VARDIR/tilecache.png" |
621 | or die "$VARDIR/tilecache.png: $!"; |
628 | or die "$VARDIR/tilecache.png: $!"; |
622 | *FACE = $_[0]; |
629 | *FACE = $_[0]; |
623 | }, sub { |
630 | }, sub { |
624 | require File::Temp; |
|
|
625 | |
|
|
626 | my $tile = read_pak "$LIB/crossfire.0"; |
631 | my $tile = read_pak "$LIB/crossfire.0"; |
627 | |
632 | |
628 | my %cache; |
633 | my %cache; |
629 | |
634 | |
630 | my $idx = 0; |
635 | my $idx = 0; |
631 | |
636 | |
632 | for my $name (sort keys %$tile) { |
637 | for my $name (sort keys %$tile) { |
633 | my ($fh, $filename) = File::Temp::tempfile (); |
638 | my $pb = new Gtk2::Gdk::PixbufLoader; |
634 | print $fh $tile->{$name}; |
639 | $pb->write ($tile->{$name}); |
635 | close $fh; |
640 | $pb->close; |
636 | my $pb = new_from_file Gtk2::Gdk::Pixbuf $filename; |
641 | my $pb = $pb->get_pixbuf; |
637 | unlink $filename; |
|
|
638 | |
642 | |
639 | my $tile = $cache{$name} = { |
643 | my $tile = $cache{$name} = { |
640 | pb => $pb, |
644 | pb => $pb, |
641 | idx => $idx, |
645 | idx => $idx, |
642 | w => int $pb->get_width / TILESIZE, |
646 | w => int $pb->get_width / TILESIZE, |
… | |
… | |
660 | $pb, ($idx % 64) * TILESIZE, TILESIZE * int $idx / 64); |
664 | $pb, ($idx % 64) * TILESIZE, TILESIZE * int $idx / 64); |
661 | } |
665 | } |
662 | } |
666 | } |
663 | } |
667 | } |
664 | |
668 | |
665 | $pb->save ("$VARDIR/tilecache.png", "png"); |
669 | $pb->save ("$VARDIR/tilecache.png", "png", compression => 1); |
666 | |
670 | |
667 | \%cache |
671 | \%cache |
668 | }; |
672 | }; |
669 | } |
673 | } |
670 | |
674 | |