Jump to content

Photo

My take on .spl files


3 replies to this topic

#1 Galactygon

Galactygon

    Nostradoctopus

  • Modders
  • 728 posts
  • Gender:Male
  • Location:Sweden

Posted 31 August 2008 - 07:10 AM

I. Introduction

I am intending this lecture/essay for those who are fairly comfortable going in and editing .spl files. Therefore, I am not going over the definition of an extended header or an effect. For now, I am making a single post. If I have the time/energy/motivation, I will make additional posts. I hope this first post is readable, I made amendments after amendments.

So why bother with .spl files, even if you are not interested in spell-related mods? I have worked for years with .spl files, and people have seen the stuff they could do - there is practically no limit.

At a first glance, .spl files seem relatively limited - there are extended headers and then there are effects slapped onto extended headers. These effects can do all sorts of stuff, and the extended headers tell you what effects are called. Opcodes determine what each of the effects do, and there are only so many of them.

In .spl files, there is no straightforward way to check for conditions like you do in .bcs blocks. A typical .bcs block goes like this:

IF
A is true
B is true
THEN
C happens
D happens

Wheras a typical extended header looks like this:

A happens.
B happens.

Once you start figuring how to manipulate .spl files to mimick certain "IF" blocks, it is easier and more reliable to mess around with .spl files than .baf files. You can use other .spl files to exclude A or B, but this isn't always trivial. I will explain how to do this in some later post.

You should notice that in scripts, the game engine is continuously checking what blocks are true before executing them, while in extended headers, a whole bunch of stuff is executed at once with only one check (level required to call the extended header). This difference has a major impact on game performance. In addition, .bcs blocks aren't always executed smoothly - the timing might be off by one AI framerate who knows. On the other hand, extended headers are executed completely mechanically - you can always rely on them. Through a string of .spl files, you can mimick opcodes from other game engines, or even construct your own! This is not even remotely possible in .bcs files.

For example, you can construct an opcode that grants bonuses to saving throws that is not cumulative with itself, and allows the player to renew them. For example, I can construct a spell that grants a bonus to saving throws, is not cumulative with itself or similar effects, and allows the player to renew the effects rather than wait for them to expire.

Another example might be to mimick critical hit rolls, and apply an effect on the creature hit when a critical hit is rolled. I could have Silver Sword kill a creature upon a critical hit rather than have an effect that always triggers with a percentile dice, and pray for the best.

All of these examples require some thought, and especially the latter is not strightforward to figure out. As mentioned earlier, I have strings of .spl files execute these tasks, it is not uncommon for me to employ 10+ subspells to execute a single task. In fact, I sometimes have more than 50 .spl files in what looks like a single spell or effect (see Shroud of Flame component of SpellPack). This can sometimes be overwhelming, but after a few spells you start to realize you can keep track of what each .spl does. Organizing them helps.

Groups of .spl files can appear very complex when flipping through .spl file after .spl file in NI or DLTCEP, but from an ingame point of view they are extremely simple to handle, and unlike scripts, you can barely notice all the hundreds of effects at work.

This does not mean that we should forsake .bcs files - there are things .bcs files can do what .spl files don't and vice versa. What those things are, I cannot list them, you have to know what you're doing in order to handle them. I end up working with both where .bcs files do one check (such as an INT check), where .spl files do the rest.

If you flip through my .spl files, you will notice there is a swath of opcodes that appear in practically every single subspell. They are my best friends, I know their numbers by heart. :laugh:

The opcodes are:
#101 [Protection from Opcode]
#102 [Protection from Spell Levels]
#146 [Cast Spell at Creature]
#148 [Cast Spell at Point]
#148 [Cast Spell at Point]
#177 [Use EFF File]
#205 [Protection from Secondary Type]
#206 [Protection from Spell]
#221 [Remove Secondary Type]

And sometimes you will see:
#232 [Cast Spell on Condition]
#248 [Set Melee Effect]
#249 [Set Ranged Effect]

These opcodes are crucial as they allow effects and .spl files to interact on the level that you can mimick "IF" blocks in script files. Most of these opcodes appear only in Baldur's Gate II, therefore this level of control is not possible in some of the other games.

I am hoping to cover these opcodes one by one and put it all together in some of the later posts. But first I will have to make sure people are with me so far. Going in and doing stuff in .spl files is one thing but explaining them is completely different. I am willing to modify my posts and answer questions for the sake of clarity.

-Galactygon
Posted Image

Posted Image

#2 aVENGER_(RR)

aVENGER_(RR)
  • Modders
  • 1008 posts
  • Gender:Not Telling

Posted 31 August 2008 - 01:08 PM

Once you start figuring how to manipulate .spl files to mimick certain "IF" blocks, it is easier and more reliable to mess around with .spl files than .baf files.


Very interesting! The comparison with BAF files is spot on, especially when advanced EFF targeting techniques are concerned.

Another example might be to mimick critical hit rolls, and apply an effect on the creature hit when a critical hit is rolled. I could have Silver Sword kill a creature upon a critical hit rather than have an effect that always triggers with a percentile dice, and pray for the best.


Definitively looking forward to reading more about that. :laugh:

#3 Sorrow

Sorrow

    Omnicidal Maniac

  • Members
  • 385 posts
  • Gender:Male

Posted 01 September 2008 - 07:34 AM

I admire your creative work on spells that you've shown in Lost Crossroads.

I'm looking forward to reading further lectures :laugh: .
<p>Thought for the day:
"Crush the alien beneath your tracks."

My DA gallery
Fallout1: Fatal Damage Mod

#4 Ardanis

Ardanis

    A very GAR character

  • Modders
  • 2631 posts
  • Gender:Male
  • Location:Saint-Petersburg, Russia

Posted 03 September 2008 - 07:56 AM

I apologize for hijacking other one's tutorial, but I happened to have a ready example of spl+bcs combo on my hands. It was a test version, for a real mod I've uploaded another one with a ew fixes, but this one works as well.
http://rapidshare.co...leater.rar.html

Retired from modding.




Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users