Magnificent Ornk Aran Posted April 13, 2007 Share Posted April 13, 2007 On searching a container, the player should receive a special item (via a town state). Obviously, the walk-on special areas won't cut it for this. So instead, I used a terrain script with a SEARCH_STATE that called the relevant town state. Code: beginterrainscript;variables;short callthis;body;beginstate 0; callthis=get_memory_cell(0);break;beginstate SEARCH_STATE; run_town_script(callthis);break; The terrain script was placed on the container, and memory cell #0 was set to 16. Town state 16 is this: Code: beginstate 16; // discover key if (has_special_item(1)>0) { print_big_str("You have ",has_special_item(1)," keys."); break; } message_dialog("Among the assorted valuables that are in this chest, you also find a large brass key. Those usually come in handy elsewhere, so you pocket it.",""); change_spec_item(1,1);break; Searching the box reveals the mundane items inside it. No other output is given - neither the short debug message nor the dialog that announces the discovery of the key. It appears the state isn't being called... Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Ephesos Posted April 13, 2007 Share Posted April 13, 2007 Okay, first problem is that you have two break; calls in that state. The first one should be end(); instead. Also, you can use the terrain script specobj.txt (which can be found in most scenario folders) instead of the one you made. It's slightly more efficient... but the main difference is that instead of using the variable callthis, it just says run_town_script(get_memory_cell(0)); which is much easier. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Aran Posted April 13, 2007 Author Share Posted April 13, 2007 Um, call this an undocumented feature, but the pattern Code: beginstate x; if (get_flag(a,==1) break; do stuff; set_flag(a,b,1);break; has worked so far. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Niemand Posted April 13, 2007 Share Posted April 13, 2007 I'm surprised to learn that that does work, but that is what the end() call is supposed to be used for. It shouldn't make any difference that I can see which you use then, based on what the documentation says, but I'm going to stick with end; I'm still wary that using break might have some odd side effect. (After all, so many things in Avernumscript seem to.) Quote Link to comment Share on other sites More sharing options...
Hatchling Cockatrice Lilith Posted April 13, 2007 Share Posted April 13, 2007 Kelandon had a problem in Exodus with searching containers not calling scripts when they should have. I forget how he solved it, but talk to him about it. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted April 13, 2007 Share Posted April 13, 2007 Well, of course, the energy levels are... no, wait, sorry, just finished doing Thermo homework. The problem in Exodus was a very simple mistake in my modification of trap.txt, probably not relevant here. I don't know why you're messing with the callthis variable. Why not just use a standard specobj or my modification, Search-Block (dummy.txt in Exodus)? Nothing in the information that you've given us — other than the weird break — would lead to a problem, as far as I can see. It must be something more elaborate. If you zip the scenario and send it to me today, I'll take a look at it. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Aran Posted April 14, 2007 Author Share Posted April 14, 2007 Well, I switched to specobj, and fixed the if-clause in that state, and now it works. I don't know which it was, but under the circumstances (one day to go till the deadline) I don't feel very curious. Thanks all! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.