• Announcements

    • That Which Mourns Soundly

      Logging in   05/10/2017

      If you had an account and can't log in as of 5/9/17, this may be because of a change in logins with new forum software. You can log in using your publicly displayed name (not your username) or your email address and the password you used before.   If you have problems with this, please ask any of the mods or admins. 
Sign in to follow this  
Followers 0
BainIhrno

Question about START_STATE

12 posts in this topic

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?

Share this post


Link to post
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.

Share this post


Link to post
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.)

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

However, in this case I think you're probably fine, since you're only putting in a single conditional.

This.

 

I did something like this in Exodus, with each of the expedition towns having a crime level and flag check in the START_STATE. It runs fine.

Share this post


Link to post
Share on other sites

Thanks everyone.

 

For stolen items, I may set up the coding to lower your reputation for doing so rather than ending the scenario, under further consideration (OG&E in BoE had a reputation system).

Share this post


Link to post
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?

Share this post


Link to post
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)

Share this post


Link to post
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());

Share this post


Link to post
Share on other sites

Thanks. As long as I'm on this subject, can SDFs have a value below 0 in BoA? The current configuration has two SDFs for reputation that supplement one another, one keeps track of good deeds and one of bad deeds. Is it possible, in other words, to do with one SDF?

Share this post


Link to post
Share on other sites

I believe the answer is no on the negative value but yes on the one SDF. The way Jeff handles that in Geneforge is by setting the SDF to 100 to begin with, so instead of dealing with negative numbers, he just deals with values below 100.

Share this post


Link to post
Share on other sites

Have to be careful that a party does not increment their reputation SDF below 0 or above 255, that will cause a crash. Make alterations only happen if SDF is above A and less than (255 - A), where A is the largest possible increment for reputation.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0