Garrulous Glaahk UA Posted June 7, 2004 Share Posted June 7, 2004 My godparty is able to open Difficulty 200 doors. I present you with a modified edition of door.txt to cure this. Code: // door.txt - This is the basic script that powers all doors. If you are // working on a scenario that contains doors, DO NOT REMOVE THIS SCRIPT.// If you place a door, this script is automatically attached to it. The// default settings for the script are for a basic, unlocked door. To make it// locked, you will need to change the memory cells.// Memory Cells - // 0 - Lock level. If left at 0, door is unlocked. Otherwise, the strength/tool// use needed to get it open. If this is set to a really high number (say, 200),// it can't be unlocked by normal means// 1 - Key needed. If left at 0, no special item helps unlock the door. Otherwise,// if that party has this special item, the door automatically unlocks.// 2,3 - Coordinates for a stuff done flag. If these are 0 and 0, ignored. Otherwise,// the stuff done flag is set to 1 when the door is unlocked. If the flag is non-zero,// than when the party enters this zone, the door will ebcome unlocked.beginterrainscript; variables; short i_am_open = 0; short cur_terrain; short i_am_locked = 0; short door_opened; short choice;body;beginstate INIT_STATE; cur_terrain = terrain_in_this_spot(); if (((cur_terrain >= 14) && (cur_terrain <= 17)) || ((cur_terrain >= 50) && (cur_terrain <= 53))) i_am_open = 1; else i_am_open = 0; if (get_memory_cell(0) > 0) { i_am_locked = 1; set_mechanism_difficulty(get_memory_cell(0)); set_physical_strength(get_memory_cell(0)); if ((get_memory_cell(2) > 0) || (get_memory_cell(3) > 0)) { if (get_sdf(get_memory_cell(2),get_memory_cell(3)) > 0) i_am_locked = 0; } } break;beginstate START_STATE;break;beginstate SEARCH_STATE; if (i_am_open == 1) { print_str_color("You close the door.",2); flip_terrain(my_loc_x(),my_loc_y()); i_am_open = 0; play_sound(-59); }break;beginstate BLOCK_MOVE_STATE; if (i_am_open == 0) { block_entry(1); door_opened = 1; if ((get_memory_cell(2) > 0) || (get_memory_cell(3) > 0)) { if (get_sdf(get_memory_cell(2),get_memory_cell(3)) > 0) i_am_locked = 0; } if ((get_memory_cell(1) > 0) && (i_am_locked > 0)) { if (has_special_item(get_memory_cell(1))) { print_str_color("You have the key which unlocks this door.",2); if ((get_memory_cell(2) > 0) || (get_memory_cell(3) > 0)) set_flag(get_memory_cell(2),get_memory_cell(3),1); i_am_locked = 0; } } if ((get_memory_cell(0) > 199) && (i_am_locked)) { reset_dialog(); add_dialog_str(0, "This door has a strong magical aura around it, one stronger than you will be able to break. Even without it's magical field, the door looks extremely strong and hefty.", 0); add_dialog_str(1, "You won't be able to open this door through forceful means.", 0); add_dialog_choice(0, "OK."); run_dialog(0); end(); } if (i_am_locked) { reset_dialog(); if (get_memory_cell(1) > 0) add_dialog_str(0,"This door is locked, and you don't have the right key. You can have your strongest character try to bash it down (which requires high strength) or have your most skilled character try to pick the lock (which requires Tool Use skill and a lockpick).",0); else add_dialog_str(0,"This door is locked. You can have your strongest character try to bash it down (which requires high strength) or have your most skilled character try to pick the lock (which requires Tool Use skill and a lockpick).",0); add_dialog_choice(0,"Leave the door alone."); add_dialog_choice(1,"Try to bash it down."); add_dialog_choice(2,"Try to pick the lock."); choice = run_dialog(0); if (choice == 1) end(); if (choice == 2) { if (run_bash_door(get_physical_strength()) == FALSE) door_opened = 0; } if (choice == 3) { if (run_pick_lock(get_mechanism_difficulty()) == FALSE) door_opened = 0; else if ((get_memory_cell(2) > 0) || (get_memory_cell(3) > 0)) award_party_xp(BASE_TRAP_XP,1 + 2 * get_mechanism_difficulty()); } } if (door_opened) { print_str("You open the door."); if ((get_memory_cell(2) > 0) || (get_memory_cell(3) > 0)) set_flag(get_memory_cell(2),get_memory_cell(3),1); flip_terrain(my_loc_x(),my_loc_y()); i_am_open = 1; i_am_locked = 0; play_sound(-160); } }break;beginstate UNLOCK_SPELL_STATE; if ((i_am_open > 0) || (i_am_locked == 0)) print_str_color("Unlock Doors: The spell doesn't affect unlocked doors.",2); else { if (get_memory_cell(0) > 199) { print_str_color("Unlock Doors: The door resists the spell.",2); end(); } if (get_unlock_spell_strength() >= get_mechanism_difficulty() * 2) { print_str_color("Unlock Doors: The spell unlocks a door.",2); i_am_locked = 0; play_sound(9); if ((get_memory_cell(2) > 0) || (get_memory_cell(3) > 0)) set_flag(get_memory_cell(2),get_memory_cell(3),1); } else { print_str_color("Unlock Doors: The spell isn't strong enough to affect the door.",2); print_str_color(" (This spell usually only affects doors with magical protection.)",2); } }break;beginstate DISPEL_BARRIER_STATE; if ((i_am_open == 0) && (i_am_locked)) { print_str_color("Dispel Barrier: The spell fails to affect a locked door.",2); }break; Not thouroughly tested. Use at your own risk. Link to comment Share on other sites More sharing options...
Well-Actually War Trall Spidweb Posted June 7, 2004 Share Posted June 7, 2004 Just as a note, you might want to post these things in the Blades of Avernum Editor forum. They're much more likely to be seen by the relevant people and less likely to confuse and terrify regular players. - Jeff Vogel Link to comment Share on other sites More sharing options...
Garrulous Glaahk UA Posted June 7, 2004 Author Share Posted June 7, 2004 Good point. Thanks for moving it. Link to comment Share on other sites More sharing options...
Hatchling Cockatrice Lilith Posted June 8, 2004 Share Posted June 8, 2004 Nice scripting, although I'm not sure how much use it should see. God parties are a legitimate tool for both debugging and reviewing. Link to comment Share on other sites More sharing options...
Garrulous Glaahk UA Posted June 8, 2004 Author Share Posted June 8, 2004 Well, it also has the advantage of clearly defining which doors you can't open right now (no trying to bash down unopenable doors.) Link to comment Share on other sites More sharing options...
Well-Actually War Trall Khoth Posted June 8, 2004 Share Posted June 8, 2004 You'll only try to bash down an unopenable door once. Link to comment Share on other sites More sharing options...
Garrulous Glaahk UA Posted June 8, 2004 Author Share Posted June 8, 2004 Yes, but if you have a weak party it might not work even if it is bash-openable at your level. Bad luck, that is. Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Imban Posted June 8, 2004 Share Posted June 8, 2004 Er. BoA has no luck involved in bashing doors. Link to comment Share on other sites More sharing options...
Magnificent Ornk Aran Posted June 8, 2004 Share Posted June 8, 2004 I don't think the technical term 'luck', as defined by the BoA editor, was intended here. But hey. Link to comment Share on other sites More sharing options...
Hatchling Cockatrice Lilith Posted June 8, 2004 Share Posted June 8, 2004 There's no randomness involved either. If you can bash a particular door, you will succeed in doing so every time. Anyway, it tells you the strength of the door when you fail to open it. If it's 200, you won't try again. Link to comment Share on other sites More sharing options...
Garrulous Glaahk UA Posted June 9, 2004 Author Share Posted June 9, 2004 Yeah, I knew about how it told the difficulty after bashing. And I didn't know randomness wasn't involved in bashing, that's rather surprising. But hey, it saves you a bash. Link to comment Share on other sites More sharing options...
Ineffable Wingbolt Dahak Posted June 10, 2004 Share Posted June 10, 2004 And the common problem with the this door script is the same as the one provided by Spiderweb. The script does NOT CHECK TO SEE IF TERRAIN 174 is the current terrain. 174 is the open fence gate, but because it is excluded from the if statement you cannot shut the door. However if you open a closed fence gate the boolean variable flips allowing you to later shut it. Link to comment Share on other sites More sharing options...
Garrulous Glaahk UA Posted June 10, 2004 Author Share Posted June 10, 2004 Putting difficulty of 200 on an open fence gate is kind of pointless. And also, the manual "more than" "less than" checking is rather messy. A cleaner approach would be.. Code: short cTerrain;short openDoors[15];openDoors[] = 40; // first open door terrainopenDoors[] = 50; // first open door terrainopenDoors[] = 60; // first open door terraincTerrain = terrain_in_this_spot();if (in_array(cTerrain, openDoors)) { // do stuff} Unfortunately, Spiderweb is unlikely to ever include such array support. Or perhaps something like... Code: // Inside an Item Declarationis_open_door = 1;is_closed_door = 0; And in door.txt... Code: if (get_terrain_info('is_open_door',party_move_into_terrain() == true)) { // etc} Essentially, burying numbers that could change inside code which is likely to be duplicated (say, a very special door) is bad. Because then you have to trudge through all the scripts and change all the relevant numbers. Link to comment Share on other sites More sharing options...
Recommended Posts