… | |
… | |
13 | use base 'Exporter'; |
13 | use base 'Exporter'; |
14 | |
14 | |
15 | use Carp (); |
15 | use Carp (); |
16 | use File::Spec; |
16 | use File::Spec; |
17 | use List::Util qw(min max); |
17 | use List::Util qw(min max); |
18 | use Storable; |
18 | use Storable qw(freeze thaw); |
19 | |
19 | |
20 | our @EXPORT = qw( |
20 | our @EXPORT = qw( |
21 | read_pak read_arch *ARCH TILESIZE $TILE *FACE editor_archs arch_extents |
21 | read_pak read_arch *ARCH TILESIZE $TILE *FACE editor_archs arch_extents |
22 | ); |
22 | ); |
23 | |
23 | |
… | |
… | |
37 | msg => "endmsg", |
37 | msg => "endmsg", |
38 | lore => "endlore", |
38 | lore => "endlore", |
39 | maplore => "endmaplore", |
39 | maplore => "endmaplore", |
40 | ); |
40 | ); |
41 | |
41 | |
42 | # not used yet, maybe alphabetical is ok |
42 | # same as in server save routine, to (hopefully) be compatible |
|
|
43 | # to the other editors. |
43 | our @FIELD_ORDER = (qw(name name_pl)); |
44 | our @FIELD_ORDER = (qw( |
|
|
45 | name name_pl custom_name title race |
|
|
46 | slaying skill msg lore other_arch face |
|
|
47 | #events |
|
|
48 | animation is_animated |
|
|
49 | Str Dex Con Wis Pow Cha Int |
|
|
50 | hp maxhp sp maxsp grace maxgrace |
|
|
51 | exp perm_exp expmul |
|
|
52 | food dam luck wc ac x y speed speed_left move_state attack_movement |
|
|
53 | nrof level direction type subtype |
|
|
54 | |
|
|
55 | resist_physical resist_magic resist_fire resist_electricity |
|
|
56 | resist_cold resist_confusion resist_acid resist_drain |
|
|
57 | resist_weaponmagic resist_ghosthit resist_poison resist_slow |
|
|
58 | resist_paralyze resist_turn_undead resist_fear resist_cancellation |
|
|
59 | resist_deplete resist_death resist_chaos resist_counterspell |
|
|
60 | resist_godpower resist_holyword resist_blind resist_internal |
|
|
61 | resist_life_stealing resist_disease |
|
|
62 | |
|
|
63 | path_attuned path_repelled path_denied material materialname |
|
|
64 | value carrying weight invisible state magic |
|
|
65 | last_heal last_sp last_grace last_eat |
|
|
66 | connected glow_radius randomitems npx_status npc_program |
|
|
67 | run_away pick_up container will_apply smoothlevel |
|
|
68 | current_weapon_script weapontype tooltype elevation client_type |
|
|
69 | item_power duration range |
|
|
70 | range_modifier duration_modifier dam_modifier gen_sp_armour |
|
|
71 | move_type move_block move_allow move_on move_off move_on move_slow move_slow_penalty |
|
|
72 | |
|
|
73 | alive wiz was_wiz applied unpaid can_use_shield no_pick is_animated monster |
|
|
74 | friendly generator is_thrown auto_apply treasure player sold see_invisible |
|
|
75 | can_roll overlay_floor is_turnable is_used_up identified reflecting changing |
|
|
76 | splitting hitback startequip blocksview undead scared unaggressive |
|
|
77 | reflect_missile reflect_spell no_magic no_fix_player is_lightable tear_down |
|
|
78 | run_away pick_up unique no_drop can_cast_spell can_use_scroll can_use_range |
|
|
79 | can_use_bow can_use_armour can_use_weapon can_use_ring has_ready_range |
|
|
80 | has_ready_bow xrays is_floor lifesave no_strength sleep stand_still |
|
|
81 | random_move only_attack confused stealth cursed damned see_anywhere |
|
|
82 | known_magical known_cursed can_use_skill been_applied has_ready_scroll |
|
|
83 | can_use_rod can_use_horn make_invisible inv_locked is_wooded is_hilly |
|
|
84 | has_ready_skill has_ready_weapon no_skill_ident is_blind can_see_in_dark |
|
|
85 | is_cauldron is_dust no_steal one_hit berserk neutral no_attack no_damage |
|
|
86 | activate_on_push activate_on_release is_water use_content_on_gen is_buildable |
|
|
87 | |
|
|
88 | body_range body_arm body_torso body_head body_neck body_skill |
|
|
89 | body_finger body_shoulder body_foot body_hand body_wrist body_waist |
|
|
90 | )); |
44 | |
91 | |
45 | sub MOVE_WALK (){ 0x01 } |
92 | sub MOVE_WALK (){ 0x01 } |
46 | sub MOVE_FLY_LOW (){ 0x02 } |
93 | sub MOVE_FLY_LOW (){ 0x02 } |
47 | sub MOVE_FLY_HIGH (){ 0x04 } |
94 | sub MOVE_FLY_HIGH (){ 0x04 } |
48 | sub MOVE_FLYING (){ 0x06 } |
95 | sub MOVE_FLYING (){ 0x06 } |
… | |
… | |
56 | open my $fh, "<", $path |
103 | open my $fh, "<", $path |
57 | or die "$path: $!"; |
104 | or die "$path: $!"; |
58 | binmode $fh; |
105 | binmode $fh; |
59 | local $/; |
106 | local $/; |
60 | |
107 | |
61 | Storable::thaw <$fh> |
108 | thaw <$fh> |
62 | } |
109 | } |
63 | |
110 | |
64 | sub save_ref($$) { |
111 | sub save_ref($$) { |
65 | my ($ref, $path) = @_; |
112 | my ($ref, $path) = @_; |
66 | |
113 | |
67 | open my $fh, ">", "$path~" |
114 | open my $fh, ">", "$path~" |
68 | or die "$path~: $!"; |
115 | or die "$path~: $!"; |
69 | binmode $fh; |
116 | binmode $fh; |
70 | print $fh Storable::freeze $ref; |
117 | print $fh freeze $ref; |
71 | close $fh; |
118 | close $fh; |
72 | rename "$path~", $path |
119 | rename "$path~", $path |
73 | or die "$path: $!"; |
120 | or die "$path: $!"; |
74 | } |
121 | } |
75 | |
122 | |