00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifdef HAVE_CONFIG_H
00020 # include <config.h>
00021 #endif
00022
00023 #include "keyactions.h"
00024 #include "keys.h"
00025 #include "gump_utils.h"
00026 #include "gamewin.h"
00027 #include "mouse.h"
00028 #include "actors.h"
00029 #include "game.h"
00030 #include "exult.h"
00031 #include "exult_types.h"
00032 #include "exult_constants.h"
00033 #include "File_gump.h"
00034 #include "Scroll_gump.h"
00035 #include "cheat.h"
00036 #include "combat_opts.h"
00037 #include "ucmachine.h"
00038 #include "party.h"
00039 #include "Audio.h"
00040 #include "Gamemenu_gump.h"
00041 #include "Newfile_gump.h"
00042 #include "Face_stats.h"
00043 #include "Gump_manager.h"
00044 #include "effects.h"
00045 #include "palette.h"
00046
00047
00048
00049
00050
00051 static Actor *Get_party_member
00052 (
00053 int num
00054 )
00055 {
00056 int npc_num = 0;
00057 if (num > 0)
00058 npc_num = Game_window::get_instance()->get_party_man()->get_member(num - 1);
00059 return Game_window::get_instance()->get_npc(npc_num);
00060 }
00061
00062
00063
00064 void ActionQuit(int *params)
00065 {
00066 Game_window::get_instance()->get_gump_man()->okay_to_quit();
00067 }
00068
00069
00070 void ActionOldFileGump(int *params)
00071 {
00072 File_gump *fileio = new File_gump();
00073 Game_window::get_instance()->get_gump_man()->do_modal_gump(fileio,
00074 Mouse::hand);
00075 delete fileio;
00076 }
00077
00078
00079 void ActionMenuGump(int *params)
00080 {
00081 Gamemenu_gump *gmenu = new Gamemenu_gump();
00082 Game_window::get_instance()->get_gump_man()->do_modal_gump(gmenu,
00083 Mouse::hand);
00084 delete gmenu;
00085 }
00086
00087
00088 void ActionFileGump(int *params)
00089 {
00090 Newfile_gump *fileio = new Newfile_gump();
00091 Game_window::get_instance()->get_gump_man()->do_modal_gump(fileio,
00092 Mouse::hand);
00093 delete fileio;
00094 }
00095
00096 void ActionQuicksave(int *params)
00097 {
00098 Game_window *gwin = Game_window::get_instance();
00099 try {
00100 gwin->write();
00101 }
00102 catch(exult_exception &e) {
00103 gwin->get_effects()->center_text("Saving game failed!");
00104 return;
00105 }
00106 gwin->get_effects()->center_text("Game saved");
00107 }
00108
00109
00110 void ActionQuickrestore(int *params)
00111 {
00112 Game_window *gwin = Game_window::get_instance();
00113 try {
00114 gwin->read();
00115 }
00116 catch(exult_exception &e) {
00117 gwin->get_effects()->center_text("Restoring game failed!");
00118 return;
00119 }
00120 gwin->get_effects()->center_text("Game restored");
00121 gwin->paint();
00122 }
00123
00124
00125 void ActionAbout(int *params)
00126 {
00127 Game_window *gwin = Game_window::get_instance();
00128 Scroll_gump *scroll;
00129 scroll = new Scroll_gump();
00130
00131 scroll->add_text("Exult V"VERSION"\n");
00132 scroll->add_text("(C) 1998-2004 Exult Team\n\n");
00133 scroll->add_text("Available under the terms of the ");
00134 scroll->add_text("GNU General Public License\n\n");
00135 scroll->add_text("http://exult.sourceforge.net\n");
00136
00137 scroll->paint();
00138 do {
00139 int x, y;
00140 Get_click(x,y, Mouse::hand);
00141 } while (scroll->show_next_page());
00142 gwin->paint();
00143 delete scroll;
00144 }
00145
00146
00147 void ActionHelp(int *params)
00148 {
00149 keybinder->ShowHelp();
00150 }
00151
00152
00153 void ActionCloseGumps(int *params)
00154 {
00155 Game_window::get_instance()->get_gump_man()->close_all_gumps();
00156 }
00157
00158
00159 void ActionCloseOrMenu(int* params)
00160 {
00161 Game_window *gwin = Game_window::get_instance();
00162 if (gwin->get_gump_man()->showing_gumps(true))
00163 gwin->get_gump_man()->close_all_gumps();
00164 else
00165 ActionMenuGump(0);
00166 }
00167
00168
00169 void ActionScreenshot(int *params)
00170 {
00171 make_screenshot();
00172 }
00173
00174
00175 void ActionRepaint(int *params)
00176 {
00177 Game_window::get_instance()->paint();
00178 }
00179
00180
00181 void ActionResIncrease(int *params)
00182 {
00183 increase_resolution();
00184 }
00185
00186
00187 void ActionResDecrease(int *params)
00188 {
00189 decrease_resolution();
00190 }
00191
00192
00193 void ActionBrighter(int *params)
00194 {
00195 change_gamma(true);
00196 }
00197
00198
00199 void ActionDarker(int *params)
00200 {
00201 change_gamma(false);
00202 }
00203
00204
00205 void ActionFullscreen(int *params)
00206 {
00207 Game_window *gwin = Game_window::get_instance();
00208 gwin->get_win()->toggle_fullscreen();
00209 gwin->paint();
00210 }
00211
00212
00213
00214
00215
00216 void ActionUseItem(int *params)
00217 {
00218 if (params[1] == -1) params[1] = c_any_framenum;
00219 if (params[2] == -1) params[2] = c_any_qual;
00220 Game_window::get_instance()->activate_item(params[0], params[1], params[2]);
00221
00222 Mouse::mouse->set_speed_cursor();
00223 }
00224
00225
00226 void ActionUseFood(int *params)
00227 {
00228 Game_window *gwin = Game_window::get_instance();
00229 if (!gwin->activate_item(377) &&
00230 GAME_SI)
00231 gwin->activate_item(0x268, 20);
00232 Mouse::mouse->set_speed_cursor();
00233 }
00234
00235
00236 void ActionCombat(int *params)
00237 {
00238 Game_window *gwin = Game_window::get_instance();
00239 gwin->toggle_combat();
00240 gwin->paint();
00241 Mouse::mouse->set_speed_cursor();
00242 }
00243
00244
00245 void ActionCombatPause(int *params)
00246 {
00247 Combat::toggle_pause();
00248 Mouse::mouse->set_speed_cursor();
00249 }
00250
00251
00252 void ActionTarget(int *params)
00253 {
00254 int x, y;
00255 if (!Get_click(x, y, Mouse::greenselect))
00256 return;
00257 Game_window::get_instance()->double_clicked(x, y);
00258 Mouse::mouse->set_speed_cursor();
00259 }
00260
00261
00262
00263 void ActionInventory(int *params)
00264 {
00265 Game_window *gwin = Game_window::get_instance();
00266 static int inventory_page = -1;
00267 Actor *actor;
00268
00269 if (params[0] == -1) {
00270 Gump_manager *gump_man = gwin->get_gump_man();
00271 int party_count = gwin->get_party_man()->get_count();
00272 int shapenum;
00273
00274 for(int i=0;i<=party_count;++i)
00275 {
00276 actor = Get_party_member(i);
00277 if (!actor)
00278 continue;
00279
00280 shapenum = actor->inventory_shapenum();
00281
00282 if (!gump_man->find_gump(actor, shapenum))
00283 {
00284 gump_man->add_gump(actor, shapenum);
00285 inventory_page = i;
00286 return;
00287 }
00288 }
00289 inventory_page = (inventory_page+1)%(party_count+1);
00290 } else {
00291 inventory_page = params[0];
00292 if (inventory_page < 0 ||
00293 inventory_page > gwin->get_party_man()->get_count())
00294 return;
00295 }
00296
00297 actor = Get_party_member(inventory_page);
00298 if (actor) {
00299 actor->show_inventory();
00300 }
00301
00302 Mouse::mouse->set_speed_cursor();
00303 }
00304
00305
00306 void ActionTryKeys(int *params)
00307 {
00308 Game_window *gwin = Game_window::get_instance();
00309 int x, y;
00310 if (!Get_click(x, y, Mouse::greenselect, 0, true))
00311 return;
00312
00313 Gump *gump = gwin->get_gump_man()->find_gump(x, y);
00314 Game_object *obj;
00315 if (gump)
00316 obj = gump->find_object(x, y);
00317 else
00318 obj = gwin->find_object(x, y);
00319 if (!obj)
00320 return;
00321 int qual = obj->get_quality();
00322 Actor *party[10];
00323 int party_cnt = gwin->get_party(&party[0], 1);
00324 for (int i = 0; i < party_cnt; i++) {
00325 Actor *act = party[i];
00326 Game_object_vector keys;
00327 if (act->get_objects(keys, 641, qual, c_any_framenum)) {
00328
00329 gwin->get_usecode()->intercept_click_on_item(obj);
00330 keys[0]->activate();
00331 return;
00332 }
00333 }
00334 Mouse::mouse->flash_shape(Mouse::redx);
00335 }
00336
00337
00338
00339 void ActionStats(int *params)
00340 {
00341 Game_window *gwin = Game_window::get_instance();
00342 static int stats_page = -1;
00343 Actor *actor;
00344
00345 if (params[0] == -1) {
00346 Gump_manager *gump_man = gwin->get_gump_man();
00347 int party_count = gwin->get_party_man()->get_count();
00348 int shapenum = game->get_shape("gumps/statsdisplay");
00349
00350 for(int i=0;i<=party_count;++i)
00351 {
00352 actor = Get_party_member(i);
00353 if (!actor)
00354 continue;
00355
00356
00357 if (!gump_man->find_gump(actor, shapenum))
00358 {
00359 gump_man->add_gump(actor, shapenum);
00360 stats_page = i;
00361 return;
00362 }
00363 }
00364 stats_page = (stats_page+1)%(party_count+1);
00365 } else {
00366 stats_page = params[0];
00367 if (stats_page < 0 ||
00368 stats_page >= gwin->get_party_man()->get_count())
00369 stats_page = 0;
00370 }
00371
00372 actor = Get_party_member(stats_page);
00373 if (actor) gwin->get_gump_man()->add_gump(actor, game->get_shape("gumps/statsdisplay"));
00374
00375 Mouse::mouse->set_speed_cursor();
00376 }
00377
00378
00379 void ActionCombatStats(int* params)
00380 {
00381 Game_window *gwin = Game_window::get_instance();
00382 int cnt = gwin->get_party_man()->get_count();
00383 gwin->get_gump_man()->add_gump(gwin->get_main_actor(), game->get_shape("gumps/cstats/1") + cnt);
00384 }
00385
00386
00387 void ActionFaceStats(int* params)
00388 {
00389 Face_stats::AdvanceState();
00390 Face_stats::save_config(config);
00391 }
00392
00393
00394
00395 void ActionSIIntro(int *params)
00396 {
00397 Game_window *gwin = Game_window::get_instance();
00398 game->set_jive();
00399 game->play_intro();
00400 game->clear_jive();
00401 gwin->clear_screen(true);
00402 gwin->get_pal()->set(0);
00403 gwin->paint();
00404 gwin->get_pal()->fade(50, 1, 0);
00405 }
00406
00407
00408
00409 void ActionEndgame(int *params)
00410 {
00411 Game_window *gwin = Game_window::get_instance();
00412 game->end_game(params[0] != 1);
00413 gwin->clear_screen(true);
00414 gwin->get_pal()->set(0);
00415 gwin->paint();
00416 gwin->get_pal()->fade(50, 1, 0);
00417 }
00418
00419
00420 void ActionScrollLeft(int *params)
00421 {
00422 Game_window *gwin = Game_window::get_instance();
00423 for (int i = 16; i; i--)
00424 gwin->view_left();
00425 }
00426
00427
00428 void ActionScrollRight(int *params)
00429 {
00430 Game_window *gwin = Game_window::get_instance();
00431 for (int i = 16; i; i--)
00432 gwin->view_right();
00433 }
00434
00435
00436 void ActionScrollUp(int *params)
00437 {
00438 Game_window *gwin = Game_window::get_instance();
00439 for (int i = 16; i; i--)
00440 gwin->view_up();
00441 }
00442
00443
00444 void ActionScrollDown(int *params)
00445 {
00446 Game_window *gwin = Game_window::get_instance();
00447 for (int i = 16; i; i--)
00448 gwin->view_down();
00449 }
00450
00451
00452 void ActionWalkWest(int *params)
00453 {
00454 Game_window *gwin = Game_window::get_instance();
00455 int speed = params[0]<0?166:50;
00456 gwin->start_actor(gwin->get_width()/2-50, gwin->get_height()/2,speed);
00457 }
00458
00459
00460 void ActionWalkEast(int *params)
00461 {
00462 Game_window *gwin = Game_window::get_instance();
00463 int speed = params[0]<0?166:50;
00464 gwin->start_actor(gwin->get_width()/2+50, gwin->get_height()/2, speed);
00465 }
00466
00467
00468 void ActionWalkNorth(int *params)
00469 {
00470 Game_window *gwin = Game_window::get_instance();
00471 int speed = params[0]<0?166:50;
00472 gwin->start_actor(gwin->get_width()/2, gwin->get_height()/2-50, speed);
00473 }
00474
00475
00476 void ActionWalkSouth(int *params)
00477 {
00478 Game_window *gwin = Game_window::get_instance();
00479 int speed = params[0]<0?166:50;
00480 gwin->start_actor(gwin->get_width()/2, gwin->get_height()/2+50, speed);
00481 }
00482
00483
00484 void ActionWalkNorthEast(int *params)
00485 {
00486 Game_window *gwin = Game_window::get_instance();
00487 int speed = params[0]<0?166:50;
00488 gwin->start_actor(gwin->get_width()/2+50, gwin->get_height()/2-50, speed);
00489 }
00490
00491
00492 void ActionWalkSouthEast(int *params)
00493 {
00494 Game_window *gwin = Game_window::get_instance();
00495 int speed = params[0]<0?166:50;
00496 gwin->start_actor(gwin->get_width()/2+50, gwin->get_height()/2+50, speed);
00497 }
00498
00499
00500 void ActionWalkNorthWest(int *params)
00501 {
00502 Game_window *gwin = Game_window::get_instance();
00503 int speed = params[0]<0?166:50;
00504 gwin->start_actor(gwin->get_width()/2-50, gwin->get_height()/2-50, speed);
00505 }
00506
00507
00508 void ActionWalkSouthWest(int *params)
00509 {
00510 Game_window *gwin = Game_window::get_instance();
00511 int speed = params[0]<0?166:50;
00512 gwin->start_actor(gwin->get_width()/2-50, gwin->get_height()/2+50, speed);
00513 }
00514
00515
00516 void ActionStopWalking(int *params)
00517 {
00518 Game_window *gwin = Game_window::get_instance();
00519 gwin->stop_actor();
00520 }
00521
00522
00523 void ActionCenter(int *params)
00524 {
00525 Game_window *gwin = Game_window::get_instance();
00526 gwin->center_view(gwin->get_camera_actor()->get_tile());
00527 gwin->paint();
00528 }
00529
00530
00531 void ActionShapeBrowser(int *params)
00532 {
00533 cheat.shape_browser();
00534 }
00535
00536
00537
00538
00539
00540
00541 void ActionCreateShape(int *params)
00542 {
00543 if (params[0] == -1) {
00544 cheat.create_last_shape();
00545 } else {
00546 Game_window *gwin = Game_window::get_instance();
00547 if (params[1] == -1) params[1] = 0;
00548 if (params[2] == -1) params[2] = 1;
00549 if (params[3] == -1) params[3] = c_any_qual;
00550 gwin->get_main_actor()->add_quantity(params[2], params[0], params[3], params[1]);
00551 gwin->get_effects()->center_text("Object created");
00552 }
00553 }
00554
00555
00556 void ActionDeleteObject(int *params)
00557 {
00558 cheat.delete_object();
00559 }
00560
00561
00562 void ActionDeleteSelected(int *params)
00563 {
00564 cheat.delete_selected();
00565 }
00566
00567
00568
00569
00570
00571 void ActionMoveSelected(int *params)
00572 {
00573 cheat.move_selected(params[0], params[1], params[2]);
00574 }
00575
00576
00577 void ActionToggleEggs(int *params)
00578 {
00579 cheat.toggle_eggs();
00580 }
00581
00582
00583
00584 void ActionGodMode(int *params)
00585 {
00586 if (params[0] == -1)
00587 cheat.toggle_god();
00588 else
00589 cheat.set_god(params[0] != 0);
00590 }
00591
00592
00593 void ActionGender(int *params)
00594 {
00595 cheat.change_gender();
00596 }
00597
00598
00599 void ActionCheatHelp(int *params)
00600 {
00601 keybinder->ShowCheatHelp();
00602 }
00603
00604
00605
00606 void ActionInfravision(int *params)
00607 {
00608 if (params[0] == -1)
00609 cheat.toggle_infravision();
00610 else
00611 cheat.set_infravision(params[0] != 0);
00612 }
00613
00614
00615
00616 void ActionSkipLift(int *params)
00617 {
00618 if (params[0] == -1)
00619 cheat.dec_skip_lift();
00620 else
00621 cheat.set_skip_lift(params[0]);
00622 }
00623
00624
00625
00626 void ActionLevelup(int *params)
00627 {
00628 if (params[0] == -1) params[0] = 1;
00629 for (int i=0; i < params[0]; i++)
00630 cheat.levelup_party();
00631 }
00632
00633
00634
00635 void ActionMapEditor(int *params)
00636 {
00637 if (params[0] == -1)
00638 cheat.toggle_map_editor();
00639 else
00640 cheat.set_map_editor(params[0] != 0);
00641 }
00642
00643
00644
00645 void ActionHackMover(int *params)
00646 {
00647 if (params[0] == -1)
00648 cheat.toggle_hack_mover();
00649 else
00650 cheat.set_hack_mover(params[0] != 0);
00651 }
00652
00653
00654 void ActionMapTeleport(int *params)
00655 {
00656 cheat.map_teleport();
00657 }
00658
00659
00660 void ActionTeleport(int *params)
00661 {
00662 cheat.cursor_teleport();
00663 }
00664
00665
00666 void ActionTime(int *params)
00667 {
00668 cheat.fake_time_period();
00669 }
00670
00671
00672
00673 void ActionWizard(int *params)
00674 {
00675 if (params[0] == -1)
00676 cheat.toggle_wizard();
00677 else
00678 cheat.set_wizard(params[0] != 0);
00679 }
00680
00681
00682 void ActionHeal(int *params)
00683 {
00684 cheat.heal_party();
00685 }
00686
00687
00688 void ActionCheatScreen(int *params)
00689 {
00690 cheat.cheat_screen();
00691 }
00692
00693
00694
00695 void ActionPickPocket(int *params)
00696 {
00697 if (params[0] == -1)
00698 cheat.toggle_pickpocket();
00699 else
00700 cheat.set_pickpocket(params[0] != 0);
00701 }
00702
00703
00704
00705 void ActionNPCNumbers(int *params)
00706 {
00707 if (params[0] == -1)
00708 cheat.toggle_number_npcs();
00709 else
00710 cheat.set_number_npcs(params[0] != 0);
00711 }
00712
00713
00714
00715 void ActionGrabActor(int *params)
00716 {
00717 if (params[0] == -1)
00718 cheat.toggle_grab_actor();
00719 else
00720 cheat.set_grab_actor(params[0] != 0);
00721 }
00722
00723
00724 void ActionCut(int *params)
00725 {
00726 cheat.cut(false);
00727 }
00728
00729
00730 void ActionCopy(int *params)
00731 {
00732 cheat.cut(true);
00733 }
00734
00735
00736 void ActionPaste(int *params)
00737 {
00738 cheat.paste();
00739 }
00740
00741
00742
00743 void ActionPlayMusic(int *params)
00744 {
00745 static int mnum = 0;
00746
00747 if (params[0] == -1) {
00748 Audio::get_ptr()->start_music(mnum++, 0);
00749 } else if (params[0] == -2) {
00750 if (mnum > 0)
00751 Audio::get_ptr()->start_music(--mnum, 0);
00752 } else {
00753 mnum = params[0];
00754 Audio::get_ptr()->start_music(mnum, 0);
00755 }
00756 }
00757
00758
00759 void ActionNaked(int *params)
00760 {
00761 cheat.toggle_naked();
00762 }
00763
00764
00765 void ActionPetra(int *params)
00766 {
00767 cheat.toggle_Petra();
00768 }
00769
00770
00771 void ActionSkinColour(int *params)
00772 {
00773 cheat.change_skin();
00774 }
00775
00776
00777 void ActionSoundTester(int *params)
00778 {
00779 cheat.sound_tester();
00780 }
00781
00782 void ActionTest(int *params)
00783 {
00784 }
00785