… | |
… | |
466 | |
466 | |
467 | my $row = 0; |
467 | my $row = 0; |
468 | my $col = 0; |
468 | my $col = 0; |
469 | |
469 | |
470 | my %resist_names = ( |
470 | my %resist_names = ( |
471 | slow => "Slow (slows you down when you are hit by the spell. Monsters will have an opportunity to come near you faster and hit you more often.)", |
471 | slow => "<b>Slow</b> (slows you down when you are hit by the spell. Monsters will have an opportunity to come near you faster and hit you more often.)", |
472 | holyw => "Holy Word (resistance you against getting the fear when someone whose god doesn't like you spells the holy word on you.)", |
472 | holyw => "<b>Holy Word</b> (resistance you against getting the fear when someone whose god doesn't like you spells the holy word on you.)", |
473 | conf => "Confusion (If you are hit by confusion you will move into random directions, and likely into monsters.)", |
473 | conf => "<b>Confusion</b> (If you are hit by confusion you will move into random directions, and likely into monsters.)", |
474 | fire => "Fire (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)", |
474 | fire => "<b>Fire</b> (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)", |
475 | depl => "Depletion (some monsters and other effects can cause stats depletion)", |
475 | depl => "<b>Depletion</b> (some monsters and other effects can cause stats depletion)", |
476 | magic => "Magic (resistance to magic spells like magic missile or similar)", |
476 | magic => "<b>Magic</b> (resistance to magic spells like magic missile or similar)", |
477 | drain => "Draining (some monsters (e.g. vampires) and other effects can steal experience)", |
477 | drain => "<b>Draining</b> (some monsters (e.g. vampires) and other effects can steal experience)", |
478 | acid => "Acid (resistance to acid, acid hurts pretty much and also corrodes your weapons)", |
478 | acid => "<b>Acid</b> (resistance to acid, acid hurts pretty much and also corrodes your weapons)", |
479 | pois => "Poison (resistance to getting poisoned)", |
479 | pois => "<b>Poison</b> (resistance to getting poisoned)", |
480 | para => "Paralysation (this resistance affects the chance you get paralysed)", |
480 | para => "<b>Paralysation</b> (this resistance affects the chance you get paralysed)", |
481 | deat => "Death (resistance against death spells)", |
481 | deat => "<b>Death</b> (resistance against death spells)", |
482 | phys => "Physical (this is the resistance against physical attacks, like when a monster hit you in melee combat)", |
482 | phys => "<b>Physical</b> (this is the resistance against physical attacks, like when a monster hit you in melee combat)", |
483 | blind => "Blind (blind resistance affects the chance of a successful blinding attack)", |
483 | blind => "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)", |
484 | fear => "Fear (this attack will drive you away from monsters who cast this and hit you successfully, being resistant to this helps a lot when fighting those monsters)", |
484 | fear => "<b>Fear</b> (this attack will drive you away from monsters who cast this and hit you successfully, being resistant to this helps a lot when fighting those monsters)", |
485 | tund => "Turn undead", |
485 | tund => "<b>Turn undead</b> (affects your resistancy to various forms of 'turn undead' spells. Only relevant when you are, in fact, undead...", |
486 | elec => "Electricity (resistance againt electricity, spells like large lightning, small lightning, ...)", |
486 | elec => "<b>Electricity</b> (resistance against electricity, spells like large lightning, small lightning, ...)", |
487 | cold => "Cold (this is your resistance against cold spells like icestorm, snowstorm, ...)", |
487 | cold => "<b>Cold</b> (this is your resistance against cold spells like icestorm, snowstorm, ...)", |
488 | ghit => "Ghost hit (special attack used by ghosts and ghost-like beings)", |
488 | ghit => "<b>Ghost hit</b> (special attack used by ghosts and ghost-like beings)", |
489 | ); |
489 | ); |
490 | for (qw/slow holyw conf fire depl magic |
490 | for (qw/slow holyw conf fire depl magic |
491 | drain acid pois para deat phys |
491 | drain acid pois para deat phys |
492 | blind fear tund elec cold ghit/) |
492 | blind fear tund elec cold ghit/) |
493 | { |
493 | { |
… | |
… | |
831 | |
831 | |
832 | sub make_inventory_window { |
832 | sub make_inventory_window { |
833 | my $invwin = new CFClient::UI::FancyFrame |
833 | my $invwin = new CFClient::UI::FancyFrame |
834 | user_w => $WIDTH * (4/5), user_h => $HEIGHT * (4/5), title => "Inventory"; |
834 | user_w => $WIDTH * (4/5), user_h => $HEIGHT * (4/5), title => "Inventory"; |
835 | |
835 | |
836 | $invwin->add (my $hb = new CFClient::UI::HBox); |
836 | $invwin->add (my $hb = new CFClient::UI::HBox expand => 1); |
837 | |
837 | |
838 | $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1); |
838 | $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1); |
839 | $vb1->add (my $lbl = new CFClient::UI::Label); |
839 | $vb1->add (my $lbl = new CFClient::UI::Label); |
840 | $lbl->set_text ("Player"); |
840 | $lbl->set_text ("Player"); |
841 | $vb1->add ($INV = new CFClient::UI::Inventory expand => 1); |
841 | $vb1->add ($INV = new CFClient::UI::Inventory expand => 1); |
… | |
… | |
861 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
861 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
862 | $FULLSCREEN = $CFG->{fullscreen}; |
862 | $FULLSCREEN = $CFG->{fullscreen}; |
863 | $FAST = $CFG->{fast}; |
863 | $FAST = $CFG->{fast}; |
864 | |
864 | |
865 | CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN |
865 | CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN |
866 | or die "SDL_SetVideoMode failed!\n"; |
866 | or die "SDL_SetVideoMode failed: " . (CFClient::SDL_GetError) . "\n"; |
867 | |
867 | |
868 | $SDL_ACTIVE = 1; |
868 | $SDL_ACTIVE = 1; |
869 | $LAST_REFRESH = time - 0.01; |
869 | $LAST_REFRESH = time - 0.01; |
870 | |
870 | |
871 | CFClient::gl_init; |
871 | CFClient::gl_init; |
… | |
… | |
1011 | my %animate_object; |
1011 | my %animate_object; |
1012 | my $animate_timer; |
1012 | my $animate_timer; |
1013 | |
1013 | |
1014 | my $fps = 9; |
1014 | my $fps = 9; |
1015 | |
1015 | |
|
|
1016 | my %demo;#d# |
|
|
1017 | |
1016 | sub force_refresh { |
1018 | sub force_refresh { |
1017 | $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; |
1019 | $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; |
1018 | debug sprintf "%3.2f", $fps; |
1020 | debug sprintf "%3.2f", $fps; |
1019 | |
1021 | |
1020 | $CFClient::UI::ROOT->draw; |
1022 | $CFClient::UI::ROOT->draw; |
1021 | CFClient::SDL_GL_SwapBuffers; |
|
|
1022 | |
1023 | |
1023 | $WANT_REFRESH = 0; |
1024 | $WANT_REFRESH = 0; |
1024 | $CAN_REFRESH = 0; |
1025 | $CAN_REFRESH = 0; |
1025 | $LAST_REFRESH = $NOW; |
1026 | $LAST_REFRESH = $NOW; |
|
|
1027 | |
|
|
1028 | 0 && do { |
|
|
1029 | # some weird model-drawing code, just a joke right now |
|
|
1030 | use CFClient::OpenGL; |
|
|
1031 | |
|
|
1032 | $demo{t}{eye_auv} ||= new_from_file CFClient::Texture "eye2.png" or die; |
|
|
1033 | $demo{t}{body_auv} ||= new_from_file CFClient::Texture "body_auv3.png" or die; |
|
|
1034 | $demo{r} ||= do { |
|
|
1035 | my $mod = Compress::LZF::sthaw do { local $/; open my $fh, "<:raw:perlio", "dread.lz3"; <$fh> }; |
|
|
1036 | $mod->{v} = pack "f*", @{$mod->{v}}; |
|
|
1037 | $_ = [scalar @$_, pack "S!*", @$_] |
|
|
1038 | for values %{$mod->{g}}; |
|
|
1039 | $mod |
|
|
1040 | }; |
|
|
1041 | |
|
|
1042 | my $r = $demo{r} or die; |
|
|
1043 | |
|
|
1044 | glDepthMask 1; |
|
|
1045 | glClear GL_DEPTH_BUFFER_BIT; |
|
|
1046 | glEnable GL_TEXTURE_2D; |
|
|
1047 | glEnable GL_DEPTH_TEST; |
|
|
1048 | glEnable GL_CULL_FACE; |
|
|
1049 | glShadeModel $::FAST ? GL_FLAT : GL_SMOOTH; |
|
|
1050 | |
|
|
1051 | glMatrixMode GL_PROJECTION; |
|
|
1052 | glLoadIdentity; |
|
|
1053 | glFrustum -1 * ($::WIDTH / $::HEIGHT), 1 * ($::WIDTH / $::HEIGHT), 1, -1, 1, 10000; |
|
|
1054 | #glOrtho 0, $::WIDTH, 0, $::HEIGHT, -10000, 10000; |
|
|
1055 | glMatrixMode GL_MODELVIEW; |
|
|
1056 | glLoadIdentity; |
|
|
1057 | |
|
|
1058 | glPushMatrix; |
|
|
1059 | glTranslate 0, 0, -800; |
|
|
1060 | glScale 1, -1, 1; |
|
|
1061 | glRotate $NOW * 1000 % 36000 / 5, 0, 1, 0; |
|
|
1062 | glRotate $NOW * 1000 % 36000 / 6, 1, 0, 0; |
|
|
1063 | glRotate $NOW * 1000 % 36000 / 7, 0, 0, 1; |
|
|
1064 | glScale 50, 50, 50; |
|
|
1065 | |
|
|
1066 | glInterleavedArrays GL_T2F_N3F_V3F, 0, $r->{v}; |
|
|
1067 | while (my ($k, $v) = each %{$r->{g}}) { |
|
|
1068 | glBindTexture GL_TEXTURE_2D, ($demo{t}{$k}{name} or die); |
|
|
1069 | glDrawElements GL_TRIANGLES, $v->[0], GL_UNSIGNED_SHORT, $v->[1]; |
|
|
1070 | } |
|
|
1071 | |
|
|
1072 | glPopMatrix; |
|
|
1073 | |
|
|
1074 | glShadeModel GL_FLAT; |
|
|
1075 | glDisable GL_DEPTH_TEST; |
|
|
1076 | glDisable GL_TEXTURE_2D; |
|
|
1077 | glDepthMask 0; |
|
|
1078 | |
|
|
1079 | $WANT_REFRESH++; |
|
|
1080 | }; |
|
|
1081 | |
|
|
1082 | CFClient::SDL_GL_SwapBuffers; |
1026 | } |
1083 | } |
1027 | |
1084 | |
1028 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
1085 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
1029 | $NOW = time; |
1086 | $NOW = time; |
1030 | |
1087 | |
… | |
… | |
1156 | $self->set_texture ($id => $data); |
1213 | $self->set_texture ($id => $data); |
1157 | } |
1214 | } |
1158 | } |
1215 | } |
1159 | } |
1216 | } |
1160 | |
1217 | |
|
|
1218 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |
|
|
1219 | # (server resource,s latency, bandwidth), so this hack is warranted. |
|
|
1220 | # the right fix is to make real tiled maps with an overview file |
|
|
1221 | sub conn::send_mapinfo { |
|
|
1222 | my ($self, $data, $cb) = @_; |
|
|
1223 | |
|
|
1224 | if ($self->{map_info}[0] =~ m%^/world/world_(\d\d\d)_(\d\d\d)$%) { |
|
|
1225 | my ($wx, $wy) = ($1, $2); |
|
|
1226 | |
|
|
1227 | if ($data =~ /^spatial ([1-4]+)$/) { |
|
|
1228 | my @dx = (0, 0, 1, 0, -1); |
|
|
1229 | my @dy = (0, -1, 0, 1, 0); |
|
|
1230 | my ($dx, $dy); |
|
|
1231 | |
|
|
1232 | for (split //, $1) { |
|
|
1233 | $dx += $dx[$_]; |
|
|
1234 | $dy += $dy[$_]; |
|
|
1235 | } |
|
|
1236 | |
|
|
1237 | $cb->(spatial => 15, |
|
|
1238 | $self->{map_info}[1] - $MAP->ox + $dx * 50, |
|
|
1239 | $self->{map_info}[2] - $MAP->oy + $dy * 50, |
|
|
1240 | 50, 50, |
|
|
1241 | sprintf "/world/world_%03d_%03d", $wx + $dx, $wy + $dy |
|
|
1242 | ); |
|
|
1243 | |
|
|
1244 | return; |
|
|
1245 | } |
|
|
1246 | } |
|
|
1247 | |
|
|
1248 | $self->SUPER::send_mapinfo ($data, $cb); |
|
|
1249 | } |
|
|
1250 | |
1161 | # this method does a "flood fill" into every tile direction |
1251 | # this method does a "flood fill" into every tile direction |
1162 | # it assumes that tiles are arranged in a rectangular grid, |
1252 | # it assumes that tiles are arranged in a rectangular grid, |
1163 | # i.e. a map is the same as the left of the right map etc. |
1253 | # i.e. a map is the same as the left of the right map etc. |
1164 | # failure to comply are harmless and result in display errors |
1254 | # failure to comply are harmless and result in display errors |
1165 | # at worst. |
1255 | # at worst. |
1166 | sub conn::flood_fill { |
1256 | sub conn::flood_fill { |
1167 | my ($self, $gx, $gy, $path, $hash, $flags) = @_; |
1257 | my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_; |
1168 | |
1258 | |
1169 | # the server does not allow map paths > 6 |
1259 | # the server does not allow map paths > 6 |
1170 | return if 7 <= length $path; |
1260 | return if 7 <= length $path; |
1171 | |
1261 | |
1172 | my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; |
1262 | my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; |
1173 | |
1263 | |
1174 | for ( |
1264 | for ( |
1175 | [1, 0, -1], |
1265 | [1, 3, 0, -1], |
1176 | [2, 1, 0], |
1266 | [2, 4, 1, 0], |
1177 | [3, 0, 1], |
1267 | [3, 1, 0, 1], |
1178 | [4, -1, 0], |
1268 | [4, 2, -1, 0], |
1179 | ) { |
1269 | ) { |
1180 | my ($tile, $dx, $dy) = @$_; |
1270 | my ($tile, $tile2, $dx, $dy) = @$_; |
|
|
1271 | |
|
|
1272 | next if $block & (1 << $tile); |
|
|
1273 | my $block = $block | (1 << $tile2); |
1181 | |
1274 | |
1182 | my $gx = $gx + $dx; |
1275 | my $gx = $gx + $dx; |
1183 | my $gy = $gy + $dy; |
1276 | my $gy = $gy + $dy; |
1184 | |
1277 | |
1185 | next unless $flags & (1 << ($tile - 1)); |
1278 | next unless $flags & (1 << ($tile - 1)); |
… | |
… | |
1187 | |
1280 | |
1188 | my $neigh = $self->{neigh_map}{$hash} ||= []; |
1281 | my $neigh = $self->{neigh_map}{$hash} ||= []; |
1189 | if (my $info = $neigh->[$tile]) { |
1282 | if (my $info = $neigh->[$tile]) { |
1190 | my ($flags, $x, $y, $w, $h, $hash) = @$info; |
1283 | my ($flags, $x, $y, $w, $h, $hash) = @$info; |
1191 | |
1284 | |
1192 | $self->flood_fill ($gx, $gy, "$path$tile", $hash, $flags) |
1285 | $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) |
1193 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
1286 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
1194 | |
1287 | |
1195 | } else { |
1288 | } else { |
1196 | $self->send_mapinfo ("spatial $path$tile", sub { |
1289 | $self->send_mapinfo ("spatial $path$tile", sub { |
1197 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
1290 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
1198 | |
1291 | |
1199 | return if $mode ne "spatial"; |
1292 | return if $mode ne "spatial"; |
1200 | |
1293 | |
1201 | $x += $MAP->ox; |
1294 | $x += $MAP->ox; |
1202 | $y += $MAP->oy; |
1295 | $y += $MAP->oy; |
1203 | |
1296 | |
1204 | $self->load_map ($hash, $x, $y) |
1297 | $self->load_map ($hash, $x, $y) |
1205 | unless $self->{neigh_map}{$hash}[5]++;#d# |
1298 | unless $self->{neigh_map}{$hash}[5]++;#d# |
1206 | |
1299 | |
1207 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
1300 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
1208 | |
1301 | |
1209 | $self->flood_fill ($gx, $gy, "$path$tile", $hash, $flags) |
1302 | $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) |
1210 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
1303 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
1211 | }); |
1304 | }); |
1212 | } |
1305 | } |
1213 | } |
1306 | } |
1214 | } |
1307 | } |
… | |
… | |
1227 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
1320 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
1228 | $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, |
1321 | $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, |
1229 | ]; |
1322 | ]; |
1230 | |
1323 | |
1231 | delete $self->{neigh_grid}; |
1324 | delete $self->{neigh_grid}; |
1232 | $self->flood_fill (0, 0, "", $hash, $flags); |
|
|
1233 | |
1325 | |
1234 | $x += $ox; |
1326 | $x += $ox; |
1235 | $y += $oy; |
1327 | $y += $oy; |
1236 | |
1328 | |
1237 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
1329 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
1238 | |
1330 | |
1239 | my $map = $self->{map_info}[0]; |
|
|
1240 | $map =~ s/^.*?\/([^\/]+)$/\1/; |
1331 | (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/; |
1241 | $STATWIDS->{map}->set_text ("Map: " . $map); |
1332 | $STATWIDS->{map}->set_text ("Map: " . $map); |
1242 | |
1333 | |
1243 | $self->load_map ($hash, $x, $y); |
1334 | $self->load_map ($hash, $x, $y); |
|
|
1335 | $self->flood_fill (0, 0, 0, "", $hash, $flags); |
1244 | } |
1336 | } |
1245 | |
1337 | |
1246 | sub conn::face_find { |
1338 | sub conn::face_find { |
1247 | my ($self, $facenum, $face) = @_; |
1339 | my ($self, $facenum, $face) = @_; |
1248 | |
1340 | |
… | |
… | |
1440 | my ($self) = @_; |
1532 | my ($self) = @_; |
1441 | |
1533 | |
1442 | $self->send ("command output-sync $CFG->{output_sync}"); |
1534 | $self->send ("command output-sync $CFG->{output_sync}"); |
1443 | $self->send ("command output-count $CFG->{output_count}"); |
1535 | $self->send ("command output-count $CFG->{output_count}"); |
1444 | |
1536 | |
|
|
1537 | my $parser = new Pod::POM; |
|
|
1538 | my $pod = $parser->parse_file (CFClient::find_rcfile "pod/skill_help.pod"); |
|
|
1539 | |
|
|
1540 | my %skill_tooltip; |
|
|
1541 | |
|
|
1542 | for my $head2 ($pod->head2) { |
|
|
1543 | $skill_tooltip{$head2->title} = CFClient::pod_to_pango $head2->content; |
|
|
1544 | } |
|
|
1545 | |
1445 | for my $skill (values %{$self->{skill_info}}) { |
1546 | for my $skill (values %{$self->{skill_info}}) { |
1446 | $MAPWIDGET->add_command ("ready_skill $skill", CFClient::UI::Label::escape "Ready the skill '$skill'"); |
1547 | $MAPWIDGET->add_command ("ready_skill $skill", |
1447 | $MAPWIDGET->add_command ("use_skill $skill", CFClient::UI::Label::escape "Immediately use the skill '$skill'"); |
1548 | (CFClient::UI::Label::escape "Ready the skill '$skill'\n\n") |
|
|
1549 | . $skill_tooltip{$skill}); |
|
|
1550 | $MAPWIDGET->add_command ("use_skill $skill", |
|
|
1551 | (CFClient::UI::Label::escape "Immediately use the skill '$skill'\n\n") |
|
|
1552 | . $skill_tooltip{$skill}); |
1448 | } |
1553 | } |
1449 | } |
1554 | } |
1450 | |
1555 | |
1451 | sub conn::eof { |
1556 | sub conn::eof { |
1452 | $MAPWIDGET->clr_commands; |
1557 | $MAPWIDGET->clr_commands; |
… | |
… | |
1617 | sdl_mode => 0, |
1722 | sdl_mode => 0, |
1618 | width => 640, |
1723 | width => 640, |
1619 | height => 480, |
1724 | height => 480, |
1620 | fullscreen => 0, |
1725 | fullscreen => 0, |
1621 | fast => 0, |
1726 | fast => 0, |
1622 | map_scale => 0.5, |
1727 | map_scale => 1, |
1623 | fow_enable => 1, |
1728 | fow_enable => 1, |
1624 | fow_intensity => 0.45, |
1729 | fow_intensity => 0.45, |
1625 | fow_smooth => 0, |
1730 | fow_smooth => 0, |
1626 | gui_fontsize => 1, |
1731 | gui_fontsize => 1, |
1627 | log_fontsize => 1, |
1732 | log_fontsize => 1, |