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.71 by elmex, Thu Aug 31 21:09:32 2006 UTC vs.
Revision 1.72 by root, Mon Sep 4 17:58:51 2006 UTC

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
165my %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
194sub _add_resist($$$) {
195 my ($ob, $mask, $value) = @_;
196
197 while (my ($k, $v) = each %attack_mask) {
198 $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
166sub normalize_object($) { 203sub 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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines