Peculiar error?

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: Peculiar error?
Apprentice
Member # 5294
Profile Homepage #0
Hi all,

Have the following creature script (it has debug lines in it):
// thief.txt
// - based off of basicnpc
// A very simple, naive text. Creature attacks anything it hates nearby.
// Once it has won, it returns to its home.
// In addition, will occasionally, based on level, will attempt to steal a
// random object from the character fighting. If successful, will then
// teleport away.
// Memory Cells:
// Cell 0 - How creature moves.
// 0 - If 0, wander randomly.
// 1 - Stands still until a target appears.
// 2 - Completely immobile, even if target appears.
// Cell 1,2 - Stuff done flag. If both 0, nothing. Otherwise when this
// is killed, set to 1. (Example: If cell 1 is 3 and cell 2 is 5, when
// creature is killed, sets SDF(3,5) to 1.)
// Cell 3 - Dialogue node to start with if talked to. if left at 0, this
// character doesn't talk.
// Cell 4,5 - Coordinates of chest/spot to place stolen items at. If both
// left at zero, thief keeps item.

begincreaturescript;

variables;

short i, itm, slt, st, x, y, fl, tr, target;

body;

beginstate INIT_STATE;
if (get_memory_cell(0) == 2)
set_mobility(ME, 0);
break;

beginstate DEAD_STATE;
// Set the appropriate stuff done flag for this character being dead
if ((get_memory_cell(1) != 0) || (get_memory_cell(2) != 0))
set_flag(get_memory_cell(1), get_memory_cell(2), 1);
break;

beginstate START_STATE;
// if I have a target for some reason, go attack it
if (target_ok()) {
if (dist_to_char(get_target()) <= 16)
set_state(3);
else set_target(ME, -1);
}

// Look for a target, attack it if visible
if (select_target(ME, 8, 0)) {
do_attack();
set_state(3);
}

// Have I been hit? Strike back!
if (who_hit_me() >= 0) {
set_target(ME, who_hit_me());
do_attack();
set_state(3);
}

// Otherwise, just peacefully move around. Go back to start, if I'm too far
// from where I started.
if ((my_dist_from_start() >= 6) || ((my_dist_from_start() > 0) && (get_memory_cell(0) > 0))) {
if (get_ran(1, 1, 100) < 40)
return_to_start(ME, 1);
}
else if (get_memory_cell(0) == 0) {
fidget(ME, 25);
}

// if we're in combat and the above didn't give me anything to do, just
// stop now. Otherwise, game will keep running script, and that eats up CPU time.
if (am_i_doing_action() == FALSE)
end_combat_turn();
break;

beginstate 3; // attacking
if (target_ok() == FALSE)
set_state(START_STATE);
// try to steal?
if ((get_ran(1, 0, 100) <= get_level(my_number())) && (is_town() == 1)) {
set_state_continue(10);
}
else {
do_attack();
}
break;

beginstate TALKING_STATE;
if (get_memory_cell(3) == 0) {
print_str("Talking: It doesn't respond.");
end();
}
begin_talk_mode(get_memory_cell(3));
break;

beginstate 10;
// steal something?
print_str("Start of steal.");
i = get_target();
print_big_str("Target = ", i, "");
if ((get_memory_cell(4) == 0) && (get_memory_cell(5) == 0)) {
st = 13;
}
else {
st = 0;
}
slt = get_ran(1, st, 39);
print_big_str("Slot = ", slt, "");
itm = item_type_in_slot(i, slt);
if (itm > 0) {
// steal it and go...
print_big_str("Good item = ", itm, "");
if (st > 0) {
print_str("Before take item.");
char_take_item(i, itm);
char_give_item(my_number(), itm);
}
else {
take_item_char_item(i, slt, get_memory_cell(4), get_memory_cell(5));
}
print_str("Getting ready to leave.");
set_state_continue(11);
}
else {
do_attack();
}
break;

beginstate 11;
// teleport away (get random location (not blocked) and go)
print_str_color("The thief takes an item and slips away.", 4);
i = current_town_size();
if (i == 0)
st = 63;
else if (i == 1)
st = 47;
else
st = 31;
i = 0;
while (i == 0) {
x = get_ran(1, 0, st);
y = get_ran(1, 0, st);
// check x and y
fl = get_floor(x, y);
tr = get_terrain(x, y);
if ((((fl >= 0) && (fl <= 22)) || ((fl >= 37) && (fl <= 56)) ||
((fl >= 72) && (fl <= 78)) || ((fl >= 81) && (fl <= 91)) ||
((fl >= 95) && (fl <= 123))) &&
(((tr >= 2) && (tr <= 121)) || ((tr >= 137) && (tr <= 146)) ||
((tr >= 155) && (tr <= 165))) &&
(is_blocked() == 0)) {
i = 1;
}
// slip to location
if (i == 1) {
relocate_character(my_number(), x, y);
}
}
break;
What seems to happen is that it gets to the line 'char_take_item()' and throws the following message: 'Peculiar Error: Undefined function called'. I've been banging on this code for two days and can't figure out why it's displaying that message. Does anyone know what it means? Have I forgotten something in the script?

Mike
Posts: 30 | Registered: Wednesday, December 15 2004 08:00
...b10010b...
Member # 869
Profile Homepage #1
I know what your problem is, but you won't like it. The char_take_item() call is broken. Harangue Jeff if you want it fixed.

--------------------
The Empire Always Loses: This Time For Sure!
Posts: 9973 | Registered: Saturday, March 30 2002 08:00
Apprentice
Member # 5294
Profile Homepage #2
Dang. Should've checked the bugs list before posting. Any work-arounds?
Also, is someone maintaining alint? When running against some scripts, it flags the following valid code:
string somevar = "some val"; In fact any 'constant' string defined this way used later it also flags as an inappropriate variable.

Mike
Posts: 30 | Registered: Wednesday, December 15 2004 08:00
Off With Their Heads
Member # 4045
Profile Homepage #3
Khoth is the one to talk to about Alint.

Workarounds for the char_take_item bug tend to be heinous. Some combination of take_all_of_item, take_item, destroy_char_item, reward_give, and char_give_item might be able to get you what you need.

I admit I haven't read your script, so I have no idea what you would need to use, but these were the calls that I mucked with while trying to work around the bug in LP.

EDIT: Have you, in fact, checked that string code in BoA and made sure that it works? I've never tried doing such a thing.

[ Wednesday, April 06, 2005 14:38: Message edited by: Kelandon ]

--------------------
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
Apprentice
Member # 5294
Profile Homepage #4
Thanks for hints. I'll see about using the destroy_char_item and the char_give_item combination to see if it will do what I need. BTW, the script posted has a slight error in the is_blocked call, I forgot the x,y params.
Declaring a string constant works fine, at least in the Windows BOA version. Hopefully (since it is documented in the ed ins), it works as well in the Mac version.

Mike
Posts: 30 | Registered: Wednesday, December 15 2004 08:00