Two Script Errors (Solved)

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: Two Script Errors (Solved)
Guardian
Member # 6670
Profile Homepage #0
Grrr. Peer editing time again.

My first problem comes from a script intended to heal/charge a creature based on the current state of two SDFs. It worked fine when I linked it to some goblins to test it in a small scenario made for this purpose. Now, when I'm testing my scenario, I get:

perheal Error: Bad term in expression in line 57.

Here's the script:
// 'perheal' by Dintiradan - Version 0.2
// A very simple, naive text. Creature attacks anything it hates nearby.
// Once it has won, it returns to its home.
// Also, each round there is a chance its HP and SP changes.
// Unless Cell 5 is negative, the HP and SP will only change when the HP is below maximum.
// 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 - Odds that creature will change HP and SP on a given turn.
// The higher the number, the less of a chance.
// If left at zero, creature changes its HP and SP every turn.
// Cell 5 - Amount that creature will have its HP and SP change.
// Cell 6,7 - When this SDF is 1, the creature can change its HP and SP.
// If both left at 0, creature always changes its HP and SP.
// Cell 8,9 - When this SDF is 1, the creature stops changing its HP and SP.
// If both left at 0, creature changes according to cells 6,7.

begincreaturescript;

variables;

short i,target;

// Make all custom changes to the displayed behaviour here.
short SPARKLE_TYPE = 3; // Green healing sparkles
short SPARKLE_NUM = 4;
short SOUND = 24; // Generic priest
string DISPLAYED_TEXT = " glows for a moment, and its wounds knit.";

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 ((get_ran(1,0,get_memory_cell(4)) == 0) &&
((get_health(ME) < get_max_health(ME)) || (get_memory_cell(5) < 0)) &&
(((get_memory_cell(6) == 0) && (get_memory_cell(7) == 0)) ||
(get_flag(get_memory_cell(6),get_memory_cell(7)) == 1)) &&
(((get_memory_cell(8) == 0) && (get_memory_cell(9) == 0)) ||
(get_flag(get_memory_cell(8),get_memory_cell(9)) != 1))) {
change_char_energy(ME,get_memory_cell(5)); *** THIS IS LINE 57 ***
change_char_health(ME,get_memory_cell(5));
put_sparkles_on_char(ME,SPARKLE_TYPE,SPARKLE_NUM);
run_animation_sound(SOUND);
print_named_str(ME,DISPLAYED_TEXT);
}

// 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);
if ((get_ran(1,0,get_memory_cell(4)) == 0) &&
((get_health(ME) < get_max_health(ME)) || (get_memory_cell(5) < 0) &&
(((get_memory_cell(6) == 0) && (get_memory_cell(7) == 0)) ||
(get_flag(get_memory_cell(6),get_memory_cell(7)) == 1)) &&
(((get_memory_cell(8) == 0) && (get_memory_cell(9) == 0)) ||
(get_flag(get_memory_cell(8),get_memory_cell(9)) != 1))) {
change_char_energy(ME,get_memory_cell(5));
change_char_health(ME,get_memory_cell(5));
put_sparkles_on_char(ME,SPARKLE_TYPE,SPARKLE_NUM);
run_animation_sound(SOUND);
print_named_str(ME,DISPLAYED_TEXT);
}
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;
In all likelihood, it's a problem with that huge conditional. I already found one missing parenthesis.

My second script tries to have a monster spawn in a random close location. When running it, I get:

t4cmine Error: Missing integer in line 23.

The script is:
// 4: Crystal Mine

begintownscript;

variables;
short choice,rand_x,rand_y;

short MAX_SPAWNED = 6;
short SPAWN_ODDS = 5;
short SPAWN_RANGE = 6;

body;

beginstate INIT_STATE;
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
if ((get_flag(4,2) != 3) && (get_flag(4,1) < MAX_SPAWNED) &&
(get_ran(1,0,SPAWN_ODDS) == 0)) {
*** THE FOLLOWING IS LINE 23 ***
*** I TRIED IT A COUPLE OF WAYS, ONE IS COMMENTED OUT ***
rand_x = get_ran(1,-SPAWN_RANGE,SPAWN_RANGE) + char_loc_x(random_party_member());
rand_y = get_ran(1,-SPAWN_RANGE,SPAWN_RANGE) + char_loc_y(random_party_member());
// if (get_ran(1,0,1) == 0)
// rand_x = char_loc_x(random_party_member()) + get_ran(1,0,SPAWN_RANGE);
// else
// rand_x = char_loc_x(random_party_member()) - get_ran(1,0,SPAWN_RANGE);
// if (get_ran(1,0,1) == 0)
// rand_y = char_loc_y(random_party_member()) + get_ran(1,0,SPAWN_RANGE);
// else
// rand_y = char_loc_y(random_party_member()) - get_ran(1,0,SPAWN_RANGE);

if ((get_terrain(rand_x,rand_y) >= 450) &&
(get_terrain(rand_x,rand_y) <= 464) &&
(char_on_loc(rand_x,rand_y) == -1)) {
if (get_ran(1,0,1) == 0) {
if (has_special_item(1) == 0)
place_monster(rand_x,rand_y,243,0); // Black Shade (Invisible)
else
place_monster(rand_x,rand_y,246,0); // Black Shade (Visible)
}
else {
if (has_special_item(1) == 0)
place_monster(rand_x,rand_y,244,0); // Guardian (Invisible)
else
place_monster(rand_x,rand_y,247,0); // Guardian (Visible)
}

play_sound(-165);
print_str("A patch of fog close to you swirls around suddenly.");
inc_flag(4,1,1);
}
}
break;
I think the line numbers are reported wrong... if you need me to clarify anything just ask. Now to see if the scripts are displayed right; Notepad botches them up.

EDIT: Yep, it seems UBB likes my tabs better than Notepad. Sorry about the length, I wanted to include the entire scripts; I think the reported line errors are screwed up. Also, sorry about the current lack of useful comments. I can clarify something if you need me to.

--------------------
(Bashes head against wall. Repeatedly.)

[ Friday, April 21, 2006 14:27: Message edited by: Dintiradan ]
Posts: 1509 | Registered: Tuesday, January 10 2006 08:00
Infiltrator
Member # 5576
Profile Homepage #1
Try Alint. It shows a number of other errors in the first script alone.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Off With Their Heads
Member # 4045
Profile Homepage #2
By the way, if you have an excessively large number of AND operators, you can break them up.

if ((get_flag(50,2) == 1) && (get_flag(51,2) == 1))is the same as

if (get_flag(50,2) == 1)
if (get_flag(51,2) == 1)
But the second one is probably easier to read, especially if there are lots of conditions.

[ Friday, April 21, 2006 13:59: 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
Guardian
Member # 6670
Profile Homepage #3
Okay, got it now after taking a break then looking at it again:

In the first script, both conditionals had parens. problems. From now on, I'm going to solely rely on Programmer's Notepad. I played around with the second for a while; something I did made it work.

Don't worry: before I release the scenario, I plan to re-do the scripts for readability.

A bit more playing around with a creature script, and I'll have a dungeon where creatures spawn in random locations, while keeping a limit on the number of creatures (no more flooding dungeons).

--------------------
IF I EVER BECOME AN EVIL OVERLORD:
When arresting prisoners, my guards will not allow them to stop and grab a useless trinket of purely sentimental value.
Posts: 1509 | Registered: Tuesday, January 10 2006 08:00
Lifecrafter
Member # 6193
Profile Homepage #4
[rant] Creature scripts are by far the most difficult thing for me to work with. Doing anything beyond the most basic task is a lesson in futility and weird errors. [/rant]

I'm sorry you all had to hear that, it's been a long day fiddling with defective creature scripts.

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
Master
Member # 5977
Profile Homepage #5
quote:
Originally written by Kelandon:

By the way, if you have an excessively large number of AND operators, you can break them up.

if ((get_flag(50,2) == 1) && (get_flag(51,2) == 1))is the same as

if (get_flag(50,2) == 1)
if (get_flag(51,2) == 1)
But the second one is probably easier to read, especially if there are lots of conditions.

Oh... Is that how one writes them? I tried them multiple times, but I never succeeded in doing it the right way. Thanks, kelandon.

--------------------
Play and rate my scenarios:

Where the rivers meet
View my upcoming scenario: The Nephil Search: Escape.

Give us your drek!
Posts: 3029 | Registered: Saturday, June 18 2005 07:00
Off With Their Heads
Member # 4045
Profile Homepage #6
How one writes what? Did you just say, "Is that how one writes conditions?" Or "Is that how one writes AND operators?"

--------------------
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
Lifecrafter
Member # 6193
Profile Homepage #7
For the sake of your beta testers I hope its the second.

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
Lifecrafter
Member # 6193
Profile Homepage #8
Edit: Stupid UBB makin me double post. I'll try to salvage this, Err, "How about those boolean opperators eh? What a group of characters!"

[ Saturday, April 22, 2006 06:09: Message edited by: Lazarus. ]

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
Shaper
Member # 3442
Profile Homepage #9
quote:
Originally written by Lazarus.:

Edit: Stupid UBB makin me double post. I'll try to salvage this, Err, "How about those boolean opperators eh? What a group of characters!"
This bought me more joy than you can ever imagine... I need to get out more.

And to add fuel to the "&&" argument (is it an argument yet?), I tend to do it like this:

if((get_flag(x,y) == z) && (get_flag(a,b) != c)) { For some reason, I think it's more clearer than writing

if(get_flag(x,y) == z) {
if(get_flag(a,b) != c) {
do_something_here();
}
}


--------------------
And when you want to Live
How do you start?
Where do you go?
Who do you need to know?

Posts: 2864 | Registered: Monday, September 8 2003 07:00
Guardian
Member # 6670
Profile Homepage #10
Yeah, sorry about the huge, one-line conditionals. An unfortunate side-effect of taking a programming course where Perl was the language used. It became a friendly competition to see how few lines the assignments could be done in.

Meh. I don't mind scripts. It's the moment of satisfaction when the thing finally works, after spending a few hours rooting out one bug.

(And yes, the scripts work now. I've forgotten how scary black shades and guardians could be.)

--------------------
IF I EVER BECOME AN EVIL OVERLORD:
My door mechanisms will be designed so that blasting the control panel on the outside seals the door and blasting the control panel on the inside opens the door, not vice versa.
Posts: 1509 | Registered: Tuesday, January 10 2006 08:00
Master
Member # 5977
Profile Homepage #11
quote:
Originally written by Lazarus.:

For the sake of your beta testers I hope its the second.
I don't really know how that would help the beta-tester. they are all as in the first example that Kelandon gave, and I really hope you don't expect that I start changing it now.

kelandon: I meant the AND-operators.

--------------------
Play and rate my scenarios:

Where the rivers meet
View my upcoming scenario: The Nephil Search: Escape.

Give us your drek!
Posts: 3029 | Registered: Saturday, June 18 2005 07:00
Lifecrafter
Member # 6193
Profile Homepage #12
I read it as Kel thinking you might be thanking him for showing you how to write boolean statements in general, maybe I was wrong. My reply about "for the sake of your bea testers" was me thinking of bea-testing a scenario without any boolean statements (probably not even possible.)

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00