… | |
… | |
160 | close $fh; |
160 | close $fh; |
161 | rename "$path~", $path |
161 | rename "$path~", $path |
162 | or die "$path: $!"; |
162 | or die "$path: $!"; |
163 | } |
163 | } |
164 | |
164 | |
|
|
165 | my %attack_mask = ( |
|
|
166 | physical => 0x00000001, |
|
|
167 | magic => 0x00000002, |
|
|
168 | fire => 0x00000004, |
|
|
169 | electricity => 0x00000008, |
|
|
170 | cold => 0x00000010, |
|
|
171 | confusion => 0x00000020, |
|
|
172 | acid => 0x00000040, |
|
|
173 | drain => 0x00000080, |
|
|
174 | weaponmagic => 0x00000100, |
|
|
175 | ghosthit => 0x00000200, |
|
|
176 | poison => 0x00000400, |
|
|
177 | slow => 0x00000800, |
|
|
178 | paralyze => 0x00001000, |
|
|
179 | turn_undead => 0x00002000, |
|
|
180 | fear => 0x00004000, |
|
|
181 | cancellation => 0x00008000, |
|
|
182 | deplete => 0x00010000, |
|
|
183 | death => 0x00020000, |
|
|
184 | chaos => 0x00040000, |
|
|
185 | counterspell => 0x00080000, |
|
|
186 | godpower => 0x00100000, |
|
|
187 | holyword => 0x00200000, |
|
|
188 | blind => 0x00400000, |
|
|
189 | internal => 0x00800000, |
|
|
190 | life_stealing => 0x01000000, |
|
|
191 | disease => 0x02000000, |
|
|
192 | ); |
|
|
193 | |
|
|
194 | sub _add_resist($$$) { |
|
|
195 | my ($ob, $mask, $value) = @_; |
|
|
196 | |
|
|
197 | while (my ($k, $v) = each %attack_mask) { |
|
|
198 | $ob->{"resist_$k"} = min 100, max -100, $ob->{"resist_$k"} + $value if $mask & $v; |
|
|
199 | } |
|
|
200 | } |
|
|
201 | |
165 | # object as in "Object xxx", i.e. archetypes |
202 | # object as in "Object xxx", i.e. archetypes |
166 | sub normalize_object($) { |
203 | sub normalize_object($) { |
167 | my ($ob) = @_; |
204 | my ($ob) = @_; |
168 | |
205 | |
169 | # nuke outdated or never supported fields |
206 | # nuke outdated or never supported fields |
170 | delete $ob->{$_} for qw( |
207 | delete @$ob{qw( |
171 | can_knockback can_parry can_impale can_cut can_dam_armour |
208 | can_knockback can_parry can_impale can_cut can_dam_armour |
172 | can_apply pass_thru can_pass_thru |
209 | can_apply pass_thru can_pass_thru |
173 | ); |
210 | )}; |
|
|
211 | |
|
|
212 | if (my $mask = delete $ob->{immune} ) { _add_resist $ob, $mask, 100; } |
|
|
213 | if (my $mask = delete $ob->{protected} ) { _add_resist $ob, $mask, 30; } |
|
|
214 | if (my $mask = delete $ob->{vulnerable}) { _add_resist $ob, $mask, -100; } |
174 | |
215 | |
175 | # convert movement strings to bitsets |
216 | # convert movement strings to bitsets |
176 | for my $attr (keys %FIELD_MOVEMENT) { |
217 | for my $attr (keys %FIELD_MOVEMENT) { |
177 | next unless exists $ob->{$attr}; |
218 | next unless exists $ob->{$attr}; |
178 | |
219 | |
… | |
… | |
247 | slaying => delete $ob->{"event_${event}"}, |
288 | slaying => delete $ob->{"event_${event}"}, |
248 | name => delete $ob->{"event_${event}_options"}, |
289 | name => delete $ob->{"event_${event}_options"}, |
249 | }; |
290 | }; |
250 | } |
291 | } |
251 | } |
292 | } |
|
|
293 | |
|
|
294 | # some archetypes had "+3" instead of the canonical "3", so fix |
|
|
295 | $ob->{dam} *= 1 if exists $ob->{dam}; |
252 | |
296 | |
253 | $ob |
297 | $ob |
254 | } |
298 | } |
255 | |
299 | |
256 | # arch as in "arch xxx", ie.. objects |
300 | # arch as in "arch xxx", ie.. objects |