… | |
… | |
58 | qw(move_type move_block move_allow move_on move_off move_slow); |
58 | qw(move_type move_block move_allow move_on move_off move_slow); |
59 | |
59 | |
60 | # same as in server save routine, to (hopefully) be compatible |
60 | # same as in server save routine, to (hopefully) be compatible |
61 | # to the other editors. |
61 | # to the other editors. |
62 | our @FIELD_ORDER_MAP = (qw( |
62 | our @FIELD_ORDER_MAP = (qw( |
|
|
63 | file_format_version |
63 | name attach swap_time reset_timeout fixed_resettime difficulty region |
64 | name attach swap_time reset_timeout fixed_resettime difficulty region |
64 | shopitems shopgreed shopmin shopmax shoprace |
65 | shopitems shopgreed shopmin shopmax shoprace |
65 | darkness width height enter_x enter_y msg maplore |
66 | darkness width height enter_x enter_y msg maplore |
66 | unique template |
67 | unique template |
67 | outdoor temp pressure humid windspeed winddir sky nosmooth |
68 | outdoor temp pressure humid windspeed winddir sky nosmooth |
… | |
… | |
199 | while (my ($k, $v) = each %attack_mask) { |
200 | while (my ($k, $v) = each %attack_mask) { |
200 | $ob->{"resist_$k"} = min 100, max -100, $ob->{"resist_$k"} + $value if $mask & $v; |
201 | $ob->{"resist_$k"} = min 100, max -100, $ob->{"resist_$k"} + $value if $mask & $v; |
201 | } |
202 | } |
202 | } |
203 | } |
203 | |
204 | |
|
|
205 | my %MATERIAL = reverse |
|
|
206 | paper => 1, |
|
|
207 | iron => 2, |
|
|
208 | glass => 4, |
|
|
209 | leather => 8, |
|
|
210 | wood => 16, |
|
|
211 | organic => 32, |
|
|
212 | stone => 64, |
|
|
213 | cloth => 128, |
|
|
214 | adamant => 256, |
|
|
215 | liquid => 512, |
|
|
216 | tin => 1024, |
|
|
217 | bone => 2048, |
|
|
218 | ice => 4096, |
|
|
219 | |
|
|
220 | # guesses |
|
|
221 | runestone => 12, |
|
|
222 | bronze => 18, |
|
|
223 | "ancient wood" => 20, |
|
|
224 | glass => 36, |
|
|
225 | marble => 66, |
|
|
226 | ice => 68, |
|
|
227 | stone => 70, |
|
|
228 | stone => 80, |
|
|
229 | cloth => 136, |
|
|
230 | ironwood => 144, |
|
|
231 | adamantium => 258, |
|
|
232 | glacium => 260, |
|
|
233 | blood => 544, |
|
|
234 | ; |
|
|
235 | |
204 | # object as in "Object xxx", i.e. archetypes |
236 | # object as in "Object xxx", i.e. archetypes |
205 | sub normalize_object($) { |
237 | sub normalize_object($) { |
206 | my ($ob) = @_; |
238 | my ($ob) = @_; |
|
|
239 | |
|
|
240 | # convert material bitset to materialname, if possible |
|
|
241 | if (exists $ob->{material}) { |
|
|
242 | if (!$ob->{material}) { |
|
|
243 | delete $ob->{material}; |
|
|
244 | } elsif (exists $ob->{materialname}) { |
|
|
245 | if ($MATERIAL{$ob->{material}} eq $ob->{materialname}) { |
|
|
246 | delete $ob->{material}; |
|
|
247 | } else { |
|
|
248 | warn "object $ob->{_name} has both materialname ($ob->{materialname}) and material ($ob->{material}) set.\n"; |
|
|
249 | delete $ob->{material}; # assume materilname is more specific and nuke material |
|
|
250 | } |
|
|
251 | } elsif (my $name = $MATERIAL{$ob->{material}}) { |
|
|
252 | delete $ob->{material}; |
|
|
253 | $ob->{materialname} = $name; |
|
|
254 | } else { |
|
|
255 | warn "object $ob->{_name} has unknown material ($ob->{material}) set.\n"; |
|
|
256 | } |
|
|
257 | } |
207 | |
258 | |
208 | # nuke outdated or never supported fields |
259 | # nuke outdated or never supported fields |
209 | delete @$ob{qw( |
260 | delete @$ob{qw( |
210 | can_knockback can_parry can_impale can_cut can_dam_armour |
261 | can_knockback can_parry can_impale can_cut can_dam_armour |
211 | can_apply pass_thru can_pass_thru |
262 | can_apply pass_thru can_pass_thru |
… | |
… | |
254 | if (defined (my $v = delete $ob->{slow_move})) { |
305 | if (defined (my $v = delete $ob->{slow_move})) { |
255 | $ob->{move_slow} |= MOVE_WALK; |
306 | $ob->{move_slow} |= MOVE_WALK; |
256 | $ob->{move_slow_penalty} = $v; |
307 | $ob->{move_slow_penalty} = $v; |
257 | } |
308 | } |
258 | if (defined (my $v = delete $ob->{walk_on})) { |
309 | if (defined (my $v = delete $ob->{walk_on})) { |
259 | $ob->{move_on} = MOVE_ALL unless exists $ob->{move_on}; |
310 | $ob->{move_on} = MOVE_NONE unless exists $ob->{move_on}; |
260 | $ob->{move_on} = $v ? $ob->{move_on} | MOVE_WALK |
311 | $ob->{move_on} = $v ? $ob->{move_on} | MOVE_WALK |
261 | : $ob->{move_on} & ~MOVE_WALK; |
312 | : $ob->{move_on} & ~MOVE_WALK; |
262 | } |
313 | } |
263 | if (defined (my $v = delete $ob->{walk_off})) { |
314 | if (defined (my $v = delete $ob->{walk_off})) { |
264 | $ob->{move_off} = MOVE_ALL unless exists $ob->{move_off}; |
315 | $ob->{move_off} = MOVE_NONE unless exists $ob->{move_off}; |
265 | $ob->{move_off} = $v ? $ob->{move_off} | MOVE_WALK |
316 | $ob->{move_off} = $v ? $ob->{move_off} | MOVE_WALK |
266 | : $ob->{move_off} & ~MOVE_WALK; |
317 | : $ob->{move_off} & ~MOVE_WALK; |
267 | } |
318 | } |
268 | if (defined (my $v = delete $ob->{fly_on})) { |
319 | if (defined (my $v = delete $ob->{fly_on})) { |
269 | $ob->{move_on} = MOVE_ALL unless exists $ob->{move_on}; |
320 | $ob->{move_on} = MOVE_NONE unless exists $ob->{move_on}; |
270 | $ob->{move_on} = $v ? $ob->{move_on} | MOVE_FLY_LOW |
321 | $ob->{move_on} = $v ? $ob->{move_on} | MOVE_FLY_LOW |
271 | : $ob->{move_on} & ~MOVE_FLY_LOW; |
322 | : $ob->{move_on} & ~MOVE_FLY_LOW; |
272 | } |
323 | } |
273 | if (defined (my $v = delete $ob->{fly_off})) { |
324 | if (defined (my $v = delete $ob->{fly_off})) { |
274 | $ob->{move_off} = MOVE_ALL unless exists $ob->{move_off}; |
325 | $ob->{move_off} = MOVE_NONE unless exists $ob->{move_off}; |
275 | $ob->{move_off} = $v ? $ob->{move_off} | MOVE_FLY_LOW |
326 | $ob->{move_off} = $v ? $ob->{move_off} | MOVE_FLY_LOW |
276 | : $ob->{move_off} & ~MOVE_FLY_LOW; |
327 | : $ob->{move_off} & ~MOVE_FLY_LOW; |
277 | } |
328 | } |
278 | if (defined (my $v = delete $ob->{flying})) { |
329 | if (defined (my $v = delete $ob->{flying})) { |
279 | $ob->{move_type} = MOVE_ALL unless exists $ob->{move_type}; |
330 | $ob->{move_type} = MOVE_NONE unless exists $ob->{move_type}; |
280 | $ob->{move_type} = $v ? $ob->{move_type} | MOVE_FLY_LOW |
331 | $ob->{move_type} = $v ? $ob->{move_type} | MOVE_FLY_LOW |
281 | : $ob->{move_type} & ~MOVE_FLY_LOW; |
332 | : $ob->{move_type} & ~MOVE_FLY_LOW; |
282 | } |
333 | } |
283 | |
334 | |
284 | # convert idiotic event_xxx things into objects |
335 | # convert idiotic event_xxx things into objects |
… | |
… | |
517 | |
568 | |
518 | my $inv = delete $a{inventory}; |
569 | my $inv = delete $a{inventory}; |
519 | my $more = delete $a{more}; # arches do not support 'more', but old maps can contain some |
570 | my $more = delete $a{more}; # arches do not support 'more', but old maps can contain some |
520 | my $anim = delete $a{anim}; |
571 | my $anim = delete $a{anim}; |
521 | |
572 | |
|
|
573 | if ($a{_atype} eq 'object') { |
|
|
574 | $str .= join "\n", "anim", @$anim, "mina\n" |
|
|
575 | if $anim; |
|
|
576 | } |
|
|
577 | |
522 | my @kv; |
578 | my @kv; |
523 | |
579 | |
524 | for ($a{_name} eq "map" |
580 | for ($a{_name} eq "map" |
525 | ? @Crossfire::FIELD_ORDER_MAP |
581 | ? @Crossfire::FIELD_ORDER_MAP |
526 | : @Crossfire::FIELD_ORDER) { |
582 | : @Crossfire::FIELD_ORDER) { |
… | |
… | |
570 | } |
626 | } |
571 | } |
627 | } |
572 | |
628 | |
573 | if ($inv) { |
629 | if ($inv) { |
574 | $append->($_) for @$inv; |
630 | $append->($_) for @$inv; |
575 | } |
|
|
576 | |
|
|
577 | if ($a{_atype} eq 'object') { |
|
|
578 | $str .= join "\n", "anim", @$anim, "mina\n" |
|
|
579 | if $anim; |
|
|
580 | } |
631 | } |
581 | |
632 | |
582 | $str .= "end\n"; |
633 | $str .= "end\n"; |
583 | |
634 | |
584 | if ($a{_atype} eq 'object') { |
635 | if ($a{_atype} eq 'object') { |
… | |
… | |
745 | ]; |
796 | ]; |
746 | |
797 | |
747 | $attr |
798 | $attr |
748 | } |
799 | } |
749 | |
800 | |
750 | sub arch_edit_sections { |
|
|
751 | # if (edit_type == IGUIConstants.TILE_EDIT_NONE) |
|
|
752 | # edit_type = 0; |
|
|
753 | # else if (edit_type != 0) { |
|
|
754 | # // all flags from 'check_type' must be unset in this arch because they get recalculated now |
|
|
755 | # edit_type &= ~check_type; |
|
|
756 | # } |
|
|
757 | # |
|
|
758 | # } |
|
|
759 | # if ((check_type & IGUIConstants.TILE_EDIT_MONSTER) != 0 && |
|
|
760 | # getAttributeValue("alive", defarch) == 1 && |
|
|
761 | # (getAttributeValue("monster", defarch) == 1 || |
|
|
762 | # getAttributeValue("generator", defarch) == 1)) { |
|
|
763 | # // Monster: monsters/npcs/generators |
|
|
764 | # edit_type |= IGUIConstants.TILE_EDIT_MONSTER; |
|
|
765 | # } |
|
|
766 | # if ((check_type & IGUIConstants.TILE_EDIT_WALL) != 0 && |
|
|
767 | # arch_type == 0 && getAttributeValue("no_pass", defarch) == 1) { |
|
|
768 | # // Walls |
|
|
769 | # edit_type |= IGUIConstants.TILE_EDIT_WALL; |
|
|
770 | # } |
|
|
771 | # if ((check_type & IGUIConstants.TILE_EDIT_CONNECTED) != 0 && |
|
|
772 | # getAttributeValue("connected", defarch) != 0) { |
|
|
773 | # // Connected Objects |
|
|
774 | # edit_type |= IGUIConstants.TILE_EDIT_CONNECTED; |
|
|
775 | # } |
|
|
776 | # if ((check_type & IGUIConstants.TILE_EDIT_EXIT) != 0 && |
|
|
777 | # arch_type == 66 || arch_type == 41 || arch_type == 95) { |
|
|
778 | # // Exit: teleporter/exit/trapdoors |
|
|
779 | # edit_type |= IGUIConstants.TILE_EDIT_EXIT; |
|
|
780 | # } |
|
|
781 | # if ((check_type & IGUIConstants.TILE_EDIT_TREASURE) != 0 && |
|
|
782 | # getAttributeValue("no_pick", defarch) == 0 && (arch_type == 4 || |
|
|
783 | # arch_type == 5 || arch_type == 36 || arch_type == 60 || |
|
|
784 | # arch_type == 85 || arch_type == 111 || arch_type == 123 || |
|
|
785 | # arch_type == 124 || arch_type == 130)) { |
|
|
786 | # // Treasure: randomtreasure/money/gems/potions/spellbooks/scrolls |
|
|
787 | # edit_type |= IGUIConstants.TILE_EDIT_TREASURE; |
|
|
788 | # } |
|
|
789 | # if ((check_type & IGUIConstants.TILE_EDIT_DOOR) != 0 && |
|
|
790 | # arch_type == 20 || arch_type == 23 || arch_type == 26 || |
|
|
791 | # arch_type == 91 || arch_type == 21 || arch_type == 24) { |
|
|
792 | # // Door: door/special door/gates + keys |
|
|
793 | # edit_type |= IGUIConstants.TILE_EDIT_DOOR; |
|
|
794 | # } |
|
|
795 | # if ((check_type & IGUIConstants.TILE_EDIT_EQUIP) != 0 && |
|
|
796 | # getAttributeValue("no_pick", defarch) == 0 && ((arch_type >= 13 && |
|
|
797 | # arch_type <= 16) || arch_type == 33 || arch_type == 34 || |
|
|
798 | # arch_type == 35 || arch_type == 39 || arch_type == 70 || |
|
|
799 | # arch_type == 87 || arch_type == 99 || arch_type == 100 || |
|
|
800 | # arch_type == 104 || arch_type == 109 || arch_type == 113 || |
|
|
801 | # arch_type == 122 || arch_type == 3)) { |
|
|
802 | # // Equipment: weapons/armour/wands/rods |
|
|
803 | # edit_type |= IGUIConstants.TILE_EDIT_EQUIP; |
|
|
804 | # } |
|
|
805 | # |
|
|
806 | # return(edit_type); |
|
|
807 | # |
|
|
808 | # |
|
|
809 | } |
|
|
810 | |
|
|
811 | sub cache_file($$&&) { |
801 | sub cache_file($$&&) { |
812 | my ($src, $cache, $load, $create) = @_; |
802 | my ($src, $cache, $load, $create) = @_; |
813 | |
803 | |
814 | my ($size, $mtime) = (stat $src)[7,9] |
804 | my ($size, $mtime) = (stat $src)[7,9] |
815 | or Carp::croak "$src: $!"; |
805 | or Carp::croak "$src: $!"; |