Jump to content

Scenario start_state problems


Recommended Posts

I'm currently busy updating WtRM to versionb 2.0.0, but I have stumbled upon a large, worrying problem: It seems the start_state of the scenario script is only run once, while other states, after they have been triggered by the start_state, run constantly. Is there something in the following bit of code, copied out from the start_state, that could cause this behavior?

 

Code:
 beginstate START_STATE;// [string]a = 1;print_num(a);if (get_flag(28,0) == 1) {		day1 = (get_flag(250,4));				if (what_day_of_scenario() > (day1 + 1)) {				set_flag(28,0,2);				print_str_color("[string]",3);				}		if (get_flag(200,2) == 0) {				day1 = get_flag(250,4);				if (what_day_of_scenario() == (day1 + 1)) {						set_flag(200,2,1);						print_str_color("[string]",3);						}				}		} 
(Note that there is no break; call, because I didn't copy the whole start_state)

 

The reason for me believing that the start_state isn't run proparly, is that the call print_num is only run once, as the digit "1" is only displayed once. However, if I insert a "set_state_continue" call in the above if-call, that state will be run over and over again...

 

As it is now, the start_state is only run once, and then never again. That is, until you reload your saved game or start over with the entire scenario. Then the start_state is run, and again, only for one time. Then it stops.

 

Anybody have an idea what could cause this? i think the above code is the culprit, as I was working on that particulair bit of the start_state when a long time ago, when it decided to malfunction.

Link to comment
Share on other sites

Yay for double posts in less than an hour.

 

I thought this might have been important enough for a new post, otherwise correct me, edit the previous post with what I'm saying here and delete this post.

 

Anyway: I noticed that I had a lot of if-calls in which I had "set_state_continue"-calls. Indeed, when I removed them all, everything worked fine. Is this a known bug in BoA, something new, or did I do something excruciatingly stupid I still don't know off what it is?

Link to comment
Share on other sites

Kelandon: I checked all consitions probably a hundred times by now. It's all as it should be, in the right place, with the right condition, using the right flag, to be checked for the intended value. So there is no problem there.

 

No, I have placed nothing before the print_num(a) call.

 

Slartucker: I don't have any loop anywhere, and even if I did, I assume that the whole game would then freeze and not let me play on. Correct me if I'm wrong.

 

Lazarus: Yes, I know. That's just how the call works, and I know that. Problem is, is that the start_sate is never run anymore (this means it never seems to be run when I take a step, switch places or do something else that should make the start_state run), until I reload. Then the start state is run the first time, when I take a step, and all other steps I take don't trigger the start_state. Instead the state is triggered to which the set_state_continue call pointed.

 

Okay, time for a small progress update, and the way I came to the conclusion in my last post. I was talking to Nikki, who advised me to get all code out of the start_state and replace it with a print_num call, so i could start checking what bit of code is the culprit, giving me this:

 

Code:
beginstate START_STATE;print_num(a);break; 
After that, I slowly started adding in all code that was previously in the start_state. The start_state started malfunctioning when I entered this code:

 

Code:
day5 = what_day_of_scenario();if (day5 >= 120) {		day4 = (day5 - 120);		set_state_continue(13);		}[a lot more if call like the above anbd below examples were here, but I took them out for now]		if (day5 < 12) {		day4 = day5;		set_state_continue(13);		} 
The code started working again when I did this:

 

Code:
if (day5 >= 120) {		day4 = (day5 - 120);//		set_state_continue(13);		}[a lot more if call like the above anbd below examples were here, but I took them out for now]		if (day5 < 12) {		day4 = day5;//		set_state_continue(13);		} 
The reason I suspected the set_state_continue, was that I had taken out such a call in another place in the same start_state, and that managed to make things work just a bit better, so I thought I'd try it again, and it worked. Now, this is all very unfortunate, but really not such a big problem. I can just put in state 13 in all those if calls and be done with it. I'd just like to know why this happens, because I can't see anything obvious about it...

 

I checked all my other scripts to see if there was any other place in which this could occur but didn't. I found one script in which I had put a set_state_continue, but this wasn't very alarming, as it was the only state in the start_state and therefor didn't make things complicated.

Link to comment
Share on other sites

Code:
beginstate START_STATE;

// The thing with appointment mayor of Filberton

a = 1;
print_num(a);

if (get_flag(28,0) == 1) {
day1 = (get_flag(250,4));

if (what_day_of_scenario() > (day1 + 1)) {
set_flag(28,0,2);
print_str_color("[string]",3);
}

if (get_flag(200,2) == 0) {
day1 = get_flag(250,4);
if (what_day_of_scenario() == (day1 + 1)) {
set_flag(200,2,1);
print_str_color("[string]",3);
}
}
}

// The arrest of commander Johnson in Fort Filbert

if (get_flag(28,1) == 2) {
if (get_flag(12,11) == 0) {
day2 = get_flag(250,5);
if (what_day_of_scenario() == (day2 + 2)) {
set_flag(12,11,1);
}
}
}

// The destruction of the empire HQ and consequences

if (get_flag(12,11) != 1) {
if (get_flag(41,0) == 0) {
if (get_flag(121,0) == 0) {
if (what_day_of_scenario() >= 10) {
set_flag(121,0,1);
set_town_visibility(18,1);
message_dialog("[string]","");
}
}
}
}

// Sheep disappearing in town 16

day5 = what_day_of_scenario();

if (day5 >= 120) {
day4 = (day5 - 120);
set_state_continue(13);
}

if (day5 >= 108) {
day4 = (day5 - 108);
set_state_continue(13);
}

if (day5 >= 96) {
day4 = (day5 - 96);
set_state_continue(13);
}

if (day5 >= 84) {
day4 = (day5 - 84);
set_state_continue(13);
}

if (day5 >= 72) {
day4 = (day5 - 72);
set_state_continue(13);
}

if (day5 >= 60) {
day4 = (day5 - 60);
set_state_continue(13);
}

if (day5 >= 48) {
day4 = (day5 - 48);
set_state_continue(13);
}

if (day5 >= 36) {
day4 = (day5 - 36);
set_state_continue(13);
}

if (day5 >= 24) {
day4 = (day5 - 24);
set_state_continue(13);
}

if (day5 >= 12) {
day4 = (day5 - 12);
set_state_continue(13);
}

if (day5 < 12) {
day4 = day5;
set_state_continue(13);
}
break;
Link to comment
Share on other sites

I tested it, and it really does seem to execute state 13 over and over again without ever going back to the START_STATE. However, I was able to fix it by putting

Code:
set_state(START_STATE);
at the end of state 13. Also, Thralni, you should really use
Code:
day4 = day5 % 12; 
instead of that huge set of if statements.
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...