Tenderfoot Thahd Malimar Posted March 26, 2007 Share Posted March 26, 2007 So there are two scripts that I wrote that I've been trying to get to work, and they come up with various errors. One of them is newer, I haven't been banging my head against it for more than an hour. I just don't know exactly how BoA treats decimals (experimentation implies that using the "." at all in code comes up with an Improper Symbol error). If it divides, the documentation says it loses the remainder, which isn't helpful. But I can work around lack of decimals by changing some numbers around, that's annoying but not incomprehensible to me. In any event, this code is in the outdoor script, called for certain creature encounters. It's supposed to decide whether or not to attack or run away based on the average level of the party. Under 10, it'll always attack, over 40, it'll always run, around 25 (roughly the level of the scenario) it's supposed to be 50/50. The code comes up with an Improper Command error in the first line. I'm sure the problem will be obvious to you veterans. This is of course in my outdoor script file. beginstate 11; if ((0 - 10 / 3) * ((get_level(0) + get_level(1) + get_level(2) + get_level(3)) / 4) + 133) > get_ran(1,1,100)) { print_str("This group decides you look like too much trouble and avoids you."); outdoor_enc_result(2); } break; The other bit of script is one I've been bashing my head against for a couple days now, and I figure that as soon as I click the button to post this, I'm likely to come up with an answer on my own, because that's the way the world works. In any event, it's supposed to be sort of reminiscent of the Talking Skull, in that there's a random chance of a thing happening as long as you hold the item, except instead of playing a message and a sound, it damages you. This is in the main scenario script file. beginstate START_STATE; if (get_ran(1,1,100) == 1) && (has_item(473) == true) { damage_char(0,10 * has_num_of_item(473),5); damage_char(1,10 * has_num_of_item(473),5); damage_char(2,10 * has_num_of_item(473),5); damage_char(3,10 * has_num_of_item(473),5); print_str_color("Something in your pack releases a burst of freezing energy!",2); } if (get_ran(1,1,100) == 1) && (has_item(474) == true) { damage_char(0,10 * has_num_of_item(474),1); damage_char(1,10 * has_num_of_item(474),1); damage_char(2,10 * has_num_of_item(474),1); damage_char(3,10 * has_num_of_item(474),1); print_str_color("Something in your pack releases a burst of burning energy!",2); } break; Does anybody have any insights on either of these problems? I would also be filled with glee if anybody has any better ideas for how to accomplish what I'm trying to do. Or even suggestions for cleaning up my probably messy code. Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Dintiradan Posted March 26, 2007 Share Posted March 26, 2007 State 11 is missing an opening parentheses. If you don't already have one, get a text editor that does syntax highlighting (matching braces with end braces, etc.) I notice that in START_STATE, you have your conditionals like this: Quote: if (get_ran(1,1,100) == 1) && (has_item(473) == true) I wrap an extra pair of parentheses around my conditionals, like this: Quote: if ( (get_ran(1,1,100) == 1) && (has_item(473) == true) ) I can't remember if that's necessary in AvernumScript. And since I'm not on my home computer, I can't check the docs to see if there's something else wrong with your code. Hope this helps. -------------------- Prepare to be underwhelmed. - Roy (OotS #130) Quote Link to comment Share on other sites More sharing options...
Understated Ur-Drakon Nioca Posted March 26, 2007 Share Posted March 26, 2007 I'd also like to point out that you can change this: Quote: Originally written by Malimar: damage_char(0,10 * has_num_of_item(473),5); damage_char(1,10 * has_num_of_item(473),5); damage_char(2,10 * has_num_of_item(473),5); damage_char(3,10 * has_num_of_item(473),5); into this: Quote: damage_char(1000,10 * has_num_of_item(473),5); It's less effort and has the same effect. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Swimmin' Salmon Posted March 26, 2007 Share Posted March 26, 2007 State 11 Is there a reason you don't pick a random number between 10 and 40 and compare that to the party level? It seems a little simpler, and is something that could be made more general by using memory cells instead of absolutes. There is a function that retrieves the remainder of a fraction, but I forget the call. Quote Link to comment Share on other sites More sharing options...
Unflappable Drayk Lazarus. Posted March 26, 2007 Share Posted March 26, 2007 The level checking script is flawed, one because it's just hard to read, two because it doesn't account for party size. This is how I'd write it: Code: if(((get_level(0) + get_level(1) + get_level(2) + get_level(3)) / party_size()) >= get_ran(1,10,40)){} As for the damaging item, I'd suggest you make the change Nioca suggested, and also increase the timer to greater than 100, and probably with some kind of cooldown. So... Code: if(get_ran(1,100,250) <= cooldown){} With cooldown being a varialbe that's incremented in the start_state, and is reset whenever the random number comes up greater. Edit: Also, for future reference, && or || statements need extra parentheses around them, that's the cause of the script error. Quote Link to comment Share on other sites More sharing options...
Tenderfoot Thahd Malimar Posted March 26, 2007 Author Share Posted March 26, 2007 Thanks a bunch, guys! It didn't occur to me (naive as I am, or something) that text editors specifically for code might exist. Nor did it occur to me to look up what the number for the party group is, nor did it occur to me to simplify the math in that now-obvious way. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Ishad Nha Posted March 26, 2007 Share Posted March 26, 2007 Khoth's Alint program is not perfect but it usually spots most errors. (It will always reject "fl_shimmers" as wrong, it does not check for the item numbers being in the correct range&&) Quote Link to comment Share on other sites More sharing options...
Tenderfoot Thahd Malimar Posted March 26, 2007 Author Share Posted March 26, 2007 Well, now I can narrow down the errors I'm still getting to specific lines of code (that I've modified according to suggestions). damage_char(1000,(10 * has_num_of_item(473)),5); // Bad Term In Expression error here print_str("Something in your pack releases a burst of freezing energy!",2); // It claims an unmatched left parenthesis here Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Ishad Nha Posted March 26, 2007 Share Posted March 26, 2007 Khoth's Alint program is not perfect but it usually spots most errors. (It will always reject "fl_shimmers" as wrong, it does not check for the item numbers being in the correct range&&) It can be found at: http://home.sanbrunocable.com/~tommywatts03/utilities.html In plain language this is Kelandon's page, as accessed from the Neat Links hyperlink on the home page. (The Neat Stuff link is broken.) Copy the Alint program into the folder of the ported scenario; this avoids the need to move files to and from the Alint home directory. Remove spaces from the titles of all files being scanned, otherwise you can’t get the program to recognise the files. After each lot of alterations, hit the Up Arrow and Enter keys till the file comes up clean. Alint is not infallible, but between it and the Blades game you should be able to clean up the errors. Certain errors will not be detected by Alint but the game itself will give error messages. Quote Link to comment Share on other sites More sharing options...
Unflappable Drayk Lazarus. Posted March 26, 2007 Share Posted March 26, 2007 print_str(string) doesn't need a number. Change that to print_str_color(string,color) and it'll work (although it'll print in blue) As for the damage_char call, this is confusing to me. It looks alright, are you sure the line number is correct? Quote Link to comment Share on other sites More sharing options...
Tenderfoot Thahd Malimar Posted March 26, 2007 Author Share Posted March 26, 2007 Yeah, I double-checked it with the insert-a-space-before-and-after trick. Quote Link to comment Share on other sites More sharing options...
Unflappable Drayk Lazarus. Posted March 26, 2007 Share Posted March 26, 2007 That call is definitely fine, I put it into a scenario and tested it. I'm guessing there's something wrong with the conditional before it. I usually check that line errors are correct by inserting a line where I think the error is, typing "garbage;" and seeing if the game comes up with the error in the same line. Quote Link to comment Share on other sites More sharing options...
Tenderfoot Thahd Malimar Posted March 26, 2007 Author Share Posted March 26, 2007 Now it's saying "set_state_continue(11);" has a bad term. I double-checked the line using both the two-spaces test and the "garbage" test. I think something is very wrong here. Code: beginstate START_STATE;cooldown = (cooldown + 1)cooldown2 = (cooldown2 + 1)if(get_ran(1,100,250) <= cooldown) {if(has_item(473) == true) {set_state_continue(11); // bad term error here}}if(get_ran(1,100,250) <= cooldown2) {if(has_item(474) == true) {set_state_continue(12); // bad term error here, too}}break;beginstate 11; damage_char(1000,( 10 * has_num_of_item(473) ),5); print_str("Something in your pack releases a burst of freezing energy!"); cooldown = 0;break;beginstate 12; damage_char(1000,( 10 * has_num_of_item (474) ),1); print_str_color("Something in your pack releases a burst of burning energy!"); cooldown2 = 0;break; Quote Link to comment Share on other sites More sharing options...
Unflappable Drayk Lazarus. Posted March 26, 2007 Share Posted March 26, 2007 You're missing a semicolon where you're setting those variables..... Did I mention that the "garbage;" method isn't foolproof. Edit: And now for a more useful and didactic comment; BoA's error system really doesn't like missing semicolons, basically it doesn't figure out that they're missing until the next semicolon (and thus the next line of code) is run and it realises that what it just saw makes no sense. Hence strange line numbers. Quote Link to comment Share on other sites More sharing options...
Tenderfoot Thahd Malimar Posted March 26, 2007 Author Share Posted March 26, 2007 Hgnah! There we go! Now it works (and I feel a dumb). Thanks for all the help! Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk nikki. Posted March 27, 2007 Share Posted March 27, 2007 You should never feel dumb - we all had to ask questions ourselves at one point. We are here to help - and that goes to all other designers too. 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.