Special Item in a box

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: Special Item in a box
Law Bringer
Member # 2984
Profile Homepage #0
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.

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:

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

[ Thursday, April 12, 2007 20:49: Message edited by: Dr. Johann Georg Faust ]

--------------------
Encyclopaedia ErmarianaForum ArchivesForum StatisticsRSS [Topic / Forum]
My BlogPolarisI eat novels for breakfast.
Polaris is dead, long live Polaris.
Look on my works, ye mighty, and despair.
Posts: 8752 | Registered: Wednesday, May 14 2003 07:00
Law Bringer
Member # 4153
Profile Homepage #1
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.

--------------------
Gamble with Gaea, and she eats your dice.

I hate undead. I really, really, really, really hate undead. With a passion.
Posts: 4130 | Registered: Friday, March 26 2004 08:00
Law Bringer
Member # 2984
Profile Homepage #2
Um, call this an undocumented feature, but the pattern

beginstate x;
if (get_flag(a,b)==1) break;
do stuff;
set_flag(a,b,1);
break;
has worked so far.

--------------------
Encyclopaedia ErmarianaForum ArchivesForum StatisticsRSS [Topic / Forum]
My BlogPolarisI eat novels for breakfast.
Polaris is dead, long live Polaris.
Look on my works, ye mighty, and despair.
Posts: 8752 | Registered: Wednesday, May 14 2003 07:00
Infiltrator
Member # 5576
Profile Homepage #3
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.)

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
...b10010b...
Member # 869
Profile Homepage #4
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.

--------------------
The Empire Always Loses: This Time For Sure!
Posts: 9973 | Registered: Saturday, March 30 2002 08:00
Off With Their Heads
Member # 4045
Profile Homepage #5
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.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Law Bringer
Member # 2984
Profile Homepage #6
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. :P

Thanks all!

--------------------
Encyclopaedia ErmarianaForum ArchivesForum StatisticsRSS [Topic / Forum]
My BlogPolarisI eat novels for breakfast.
Polaris is dead, long live Polaris.
Look on my works, ye mighty, and despair.
Posts: 8752 | Registered: Wednesday, May 14 2003 07:00