Jump to content

Question about START_STATE


BainIhrno

Recommended Posts

In my translation of Of Good and Evil to Blades of Avernum, I'm programming the friendly towns to (1) end the scenario if you steal something (doesn't count as winning) and (2) kill you if you attack the town.

 

I know that's probably not what some BoA players want to hear, but I feel when translating the plot over to BoA, being able to attack the friendly towns and the response only being the standard "town becomes hostile" wouldn't make sense in this storyline.

 

So I have programmed this with the START_STATE command, but I'm worried that having the game check the crime level every turn will cause the game to slow down.

 

So I guess my question is, does START_STATE slow the game down if used in certain ways?

Link to comment
Share on other sites

I have used it for creating timers, in Shadow of the Stranger you need it to know when the day ends. (Some towns have separate versions for both day and night.) It seemed to work okay, no slowing down.

I don't think it will make much difference but I don't really know. IIRC crime is handled only one way, via the crime_level functions. Offhand I don't know if you can give players banishment rather than death.

Link to comment
Share on other sites

I know that's probably not what some BoA players want to hear, but I feel when translating the plot over to BoA, being able to attack the friendly towns and the response only being the standard "town becomes hostile" wouldn't make sense in this storyline.

The default behavior isn't very useful, since it can easily put a game into an un-winnable state. I, for one, see no problem with your choice to alter it.

 

So I guess my question is, does START_STATE slow the game down if used in certain ways?

Absolutely. Avernumscript is very slow, as can be seen when designers ask it to do too much. (See for example, A Visit to the Madhouse, which accumulated a fair number of complaints because of frequently running creature scripts.) However, in this case I think you're probably fine, since you're only putting in a single conditional. If you really feel paranoid, you could factor out the body of the conditional into another state and brach to it with set_state_continue() so that there's very little code actually in the START_STATE. (Assuming the interpreter in the game works as the pieces of it leftover in the editor do, even when the body of a conditional is skipped the skipping takes time proportional to the amount of code skipped.)

Link to comment
Share on other sites

Come to think of it, this will work for the current town:

short town_status(short which_town)

2- party has entered, town hates

Town goes hostile due to the crime level being reached, then this is evaluated, you can then end the scenario.

You need to distinguish between possible causes of hostility. If a PC attacks someone a flag can be set...

Link to comment
Share on other sites

  • 1 month later...

I've started alpha-testing the scenario now, and this is the configuration I used to check the crime level

 

 

beginstate START_STATE;

 

 

 

if (get_crime_level(ME) > 0 && < 5)

set_state_continue(53);

 

if (get_crime_level(ME) >= 5)

set_state_continue(54);

 

State 53 will decrease the party's reputation via SDF by 1.

State 54 will kill the party.

 

However, right now the scenario is calling state 53 on every turn in the town, and attacking the town doesn't call 54. What am I doing wrong?

Link to comment
Share on other sites

I've started alpha-testing the scenario now, and this is the configuration I used to check the crime level

 

 

beginstate START_STATE;

 

 

 

if (get_crime_level(ME) > 0 && < 5)

set_state_continue(53);

 

if (get_crime_level(ME) >= 5)

set_state_continue(54);

 

State 53 will decrease the party's reputation via SDF by 1.

State 54 will kill the party.

 

However, right now the scenario is calling state 53 on every turn in the town, and attacking the town doesn't call 54. What am I doing wrong?

START_STATE get's called every turn, so every turn it checks with the if statement. That's why it's calling 53 every turn. If you want 53 to only be called once the first time the party does something to raise the crime level and no more, then you'll need to add a flag condition. And my memory may be a bit fuzzy on this, but I think killing someone simply raises the crime level by 3. Though more importantly, there's a mistake in the syntax:

 

if (get_crime_level(ME) > 0 && < 5)

I believe should be

if (get_crime_level(ME) > 0 && get_crime_level(ME) < 5)

Link to comment
Share on other sites

The call get_crime_level() doesn't take arguments, so get rid of those ME arguments. Also, fix the && syntax as Iffy described. Finally, you'll want to have a flag in state 53 that makes it a one-time for each increase in the crime level. So, for example, you could check if the crime level equals the flag at the beginning of the state (and end the state if it does), and then set the flag equal to the crime level at the end of the state. Something like:

if (get_crime_level() == get_flag(100,0)) // assume that flag 100,0 is just tracking whether this state has been called
end();

inc_flag(100,1,get_crime_level() - get_flag(100,0)); // assume that flag 100,1 is the reputation flag — this decreases the reputation by the additional amount of the crime level

set_flag(100,0,get_crime_level());

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