Looking for scripting best practices/intermediate tips

So at this point I think I’m comfortable saying I’m out of the “beginner” stage of scripting. I understand all of the coding basics, events, variable use, the standard functions, etc. I’m comfortable scripting most anything from scratch. But I’m still struggling with a few things:

  • Best practices. I’m fine with the simple stuff, I mean the hard lessons that people learned while building a large module. For example, is it easier to write a variable script that uses local variables on an object or the object’s tag to determine different behaviors in the script?
  • Listening patterns. I was trying to decide if it would be better (less coding time/more flexible) to fire userdef events between creatures to signal things, or would it be better to set up custom listening patterns and shouts the way the default scripts use to signal when a commoner is attacked. I’m having trouble finding detailed enough information about the way those work though.
  • AI. Anyone know of any detailed discussions/descriptions on the way the default AI works? Or is my best bet to just read everything I can about “Talents”, and start experimenting?

Tag-based and variable-based scripting are both useful in different circumstances. I use tag-based all the time, as it’s marginally easier to implement (no fiddling with variables in the toolset). However, variable-based is more legible and easier to implement for functions which are shared (or might be shared) between objects with different tags. For example, to make a companion speak on entry to an area, I use tag-based, because the action is unique. To spawn a sleeping creature, I use variable-based, since I’ll probably want other sleepers later.

I’ve tweaked listening and event signalling a bit. The documentation is scattered across the Lexicon. However, I generally find it easier to script directly (when x happens, find creatures with the right tag / faction / variable / whatever, then assign commands). Arguably, listening and events are more elegant, but if you can’t remember all the intricacies, BFI is easier and works just as well.

On AI documentation, I haven’t seen anything, beyond comments in the scripts.

1 Like