Jump to content

Special Item in a box


Aran

Recommended Posts

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...
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

Well, of course, the energy levels are... no, wait, sorry, just finished doing Thermo homework. :p

 

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...