Terrain script calls

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: Terrain script calls
? Man, ? Amazing
Member # 5755
Profile #0
I'm working on a couple of scripts and have some questions on when, and how often, the default states are called.
init_state - Is this called only the first time a town is entered, or every time a town is entered?

start_state - The docs suggest this state is called every turn, but that makes no sense to me.

The code that needs a home will be checking a SDF, and will either put a sign, or remove a sign (swap with a blank graphic) depending on that value. My gut says to put it in the start state, since actions in the town could cause the sign to appear/disappear, but it seems CPU intensive to do it that way if it runs that state every click.

Any ideas?

[ Wednesday, January 25, 2006 13:43: Message edited by: Jumpin' Salmon ]

--------------------
quote:
Originally written by Kelandon:

Well, I'm at least pretty sure that Salmon is losing.


Posts: 4114 | Registered: Monday, April 25 2005 07:00
Councilor
Member # 6600
Profile Homepage #1
Start_state does check every turn so if the sign switch can be activated every turn, it makes sense to put it there. If it is only checking a SDF, I don't think it will slow the game down noticeably.

On the other hand, you could use a special encounter that the party has to walk on before seeing the sign or after triggering the switch to check whether the terrain should be switched because then it would only be called once in a while. Of course, I think terrain switches back after leaving a town, so it would also have to go into init_state. So go back to the first hand.

Dikiyoba.

Edit: Double sig. Better than a double post, I guess...

[ Sunday, January 22, 2006 17:02: Message edited by: Dikiyoba ]
Posts: 4346 | Registered: Friday, December 23 2005 08:00
Off With Their Heads
Member # 4045
Profile Homepage #2
The INIT_STATE is called every time the party enters the town.

As far as the sign, you've got two choices. You can either put it in the START_STATE — and Dikiyoba is right: a single get_flag in the START_STATE won't kill you (or even be noticeable) — or put a bunch of special encounter rectangles around the area so that the change takes place while the party is approaching the spot.

--------------------
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
? Man, ? Amazing
Member # 5755
Profile #3
Start state then. I discovered the need for this because I have more than the arbitrary maximum number of signs in my town. So I decided to make a more versatile sign script and a new terrain. Hopefully it will work, and not drive me nuts. It was not encouraging to read the docs and see the following:
quote:
How a terrain script is formatted
A creature script has to begin with the line...
*this message sponsored by the editors guild*

--------------------
quote:
Originally written by Kelandon:

Well, I'm at least pretty sure that Salmon is losing.


Posts: 4114 | Registered: Monday, April 25 2005 07:00
Councilor
Member # 6600
Profile Homepage #4
That's to weed out the complete incompetents. Or maybe it's a typo.

Dikiyoba.
Posts: 4346 | Registered: Friday, December 23 2005 08:00
Agent
Member # 5814
Profile #5
The docs are just there to make you suffer. Ripping off someone else's code is much easier and less buggy.

--------------------
quote:
Originally written by Kelandon
Well, I'm at least pretty

Posts: 1115 | Registered: Sunday, May 15 2005 07:00
Off With Their Heads
Member # 4045
Profile Homepage #6
quote:
Originally written by Not Why:

The docs are just there to make you suffer. Ripping off someone else's code is much easier and less buggy.
To reinforce this: I have never written a town script (or a creature script or anything else) from scratch. I always copy from Jeff's code and then delete what I don't wont.

And I wrote cutscene code that worked once. Now I literally copy and paste from old cutscenes every time I need a new cutscene.

--------------------
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
Councilor
Member # 6600
Profile Homepage #7
I borrow bits and pieces from other scripts (and my own too) whenever I need to do something in a script and then go to the docs if I can't find what I want. Then I test the completed script. It's slow but it works.

Dikiyoba.
Posts: 4346 | Registered: Friday, December 23 2005 08:00
Shock Trooper
Member # 932
Profile #8
quote:
Originally written by Kelandon:

To reinforce this: I have never written a town script (or a creature script or anything else) from scratch. I always copy from Jeff's code and then delete what I don't wont.
With other games I write pretty much everything from scratch - I don't care if I'm reinventing the wheel if I can do it better. (I'm not stupid: if someone does write code that is functionally equivalent or close to what I've already got, I'll use it.)

I have written a couple of scripts from scratch, but I rarely do it anymore. I've written about a half dozen mostly from scratch. I only do either of the former when it's easier to write from scratch than to adapt someone else's work.

quote:
Originally written by Not Why:

The docs are just there to make you suffer. Ripping off someone else's code is much easier and less buggy.
Frankly, someone with serious knowledge of Avernumscript and plenty of time needs to rewrite the documentation. It's not like Jeff is going to actually proof read the documentation he wrote.

--------------------
Microsoft Patents Ones, Zeroes (March 25, 1998)
"Asians are good at Starcraft because they're always squinting, thus they can see things sharply. Remember to always squint in war." ~ Sun-Tzu
Posts: 215 | Registered: Sunday, April 7 2002 08:00
Councilor
Member # 6600
Profile Homepage #9
Even if he did, people often have trouble catching their own mistakes.

Dikiyoba.
Posts: 4346 | Registered: Friday, December 23 2005 08:00
? Man, ? Amazing
Member # 5755
Profile #10
Frustrations abound.

I've decided, based on the BUGS! thread, that create_text_bubble will not work from a terrain script. Does text_bubble_on_char work from within a terrain script?? Are there any text bubble calls that work from a terrain script?

Grrr.

--------------------
quote:
Originally written by Kelandon:

Well, I'm at least pretty sure that Salmon is losing.


Posts: 4114 | Registered: Monday, April 25 2005 07:00
Off With Their Heads
Member # 4045
Profile Homepage #11
The best way to know is to try. This is probably the first law of Avernumscript programming.

--------------------
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
? Man, ? Amazing
Member # 5755
Profile #12
Well, it's done. I posted the script at The Codex. I never did find a way to get either text_bubble call to work reliably from within the script, so I used the clunky message_dialog call.

--------------------
quote:
Originally written by Kelandon:

Well, I'm at least pretty sure that Salmon is losing.


Posts: 4114 | Registered: Monday, April 25 2005 07:00