Spell Scripting

From ALFA
Revision as of 18:18, 16 October 2017 by Foambats4all (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

"Spells" may be many things, from an ability, an item property, to an actual Spell.

Creating a spell typically starts with adding a new row to the relevant 2DA file. See the spells.2da information for specifics for each column.

Impact Script

The value of the ImpactScript column is the name of the script that will fire when this spell is triggered. The acr_spells_i.nss library contains many useful functions for defining spells.

A typical impact script will follow this shell:

// Required includes.
#include "acr_spells_i"

// The entry point for our spell impact script.
void main() {
	// Precast event. Required to return TRUE to proceed.
	if ( !ACR_PrecastEvent() ) return;
	
	// Get who is casting the spell.
	object oCaster = OBJECT_SELF;
	
	// Get who or what they are casting the spell at.
	object oTarget = GetSpellTargetObject();
	
	// Get the caster level for the spell.
	int iCasterLevel = ACR_GetCorrectCasterLevel( oCaster );
	
	// Our spell will last 1 hour per caster level.
	float fDuration = ACR_GetSpellDuration( oCaster, ACR_DURATION_TYPE_PER_CL, ACR_DURATION_1H );
	
	// Do our fancy spell effects...
	[...]
	
	// Post-cast event. Cleans up spell data.
	ACR_PostcastEvent();
}