-
Notifications
You must be signed in to change notification settings - Fork 1
SRD: Effect Functions
This page provides an overview of Spellforce Framework functions which are used to work with game objects known as Effects. The Effects are similar to the spells. The Effects control their own visual display and collision logic. The Effects can be used to deliver spell subeffect or even deliver entire spell to a target. Also, the Effects can be used to implement projectile spells.
These functions are taken from the sf_effects_functions.h header file. Please, note that you don't need to include that header in your project. It is automatically included as part of the sfsf.h general interface.
This page is up-to date for version of the Spellforce Framework 1.02-beta.
Below listed all functions you can find in sf_effect_functions.h. The effect functions can be accessed using effectAPI-> prefix, provided this group was previously initialized. In order to initialize the effect functions you should,
-
Allocate a pointer to effect functions within the global scope of your project. This is done as follows:
EffectFunctions *effectAPI; -
Assign this pointer the address of Effect Functions within the main structure of the Spellforce Framework. Usually this is done as part of
InitModulefunction after the framework was initialized. This is done in the following way:effectAPI = sfsf->effectAPI;
Description:
This function is used to spawn a new effect. The function accepts following arguments:
- Effect global object (pointer).
- Effect type ID.
- Target data of a spell source.
- Target data of a spell target.
- Internal game tick when the effect should begin. To make the effect visible this number has to exceed the internal tick when the effect was spawned at least by 1.
- An effect duration specified in a certain amount of internal game ticks.
- The rectangle the effect should fit into for AoE effects.
This function returns:
- Effect index - index of the newly-created effect.
Function Signature:
uint16_t addEffect(SF_CGDEffect *_this, CGdEffectType effect_id, SF_CGdTargetData *source, SF_CGdTargetData *target, uint32_t tick_start, uint16_t tick_count, SF_Rectangle *param_6);Example Usage:
uint16_t effect_id = effectAPI->addEffect(_this->CGdEffect, kGdEffectProjectile, &source, &target,_this->OpaqueClass->current_step+distance, 1, &spell_vector);Description:
This function returns value of a given Effect XData key. The function accepts following arguments:
- Effect global object.
- Effect index.
- Effect XData key.
Function Signature:
uint32_t getEffectXData(SF_CGDEffect *_this, uint16_t effect_index, SpellDataKey key);Example Usage:
uint16_t source_index = effectAPI->getEffectXData(_this, effect_index, EFFECT_ENTITY_INDEX);Description:
This function is used to modify the specific XData of an effect. The function accepts following arguments:
- Effect global object.
- Effect index.
- Effect XData key.
- Effect XData key value.
Note: when you create a new effect, you have to manually initialize main XData keys such as ENTITY_TYPE, ENTITY_INDEX, EFFECT_DO_NOT_ADD_SUBSPELL and a few more. The entire list of obligatory keys is shown below in Example Usage.
Function Signature:
void setEffectXData(SF_CGDEffect *_this, uint16_t effect_index, SpellDataKey key, uint32_t value);Example Usage:
effectAPI->setEffectXData(_this->CGdEffect, effect_id, EFFECT_ENTITY_TYPE, 1);
effectAPI->setEffectXData(_this->CGdEffect, effect_id, EFFECT_ENTITY_TYPE2, 1);
effectAPI->setEffectXData(_this->CGdEffect, effect_id, EFFECT_ENTITY_INDEX, source_index);
effectAPI->setEffectXData(_this->CGdEffect, effect_id, EFFECT_ENTITY_INDEX2, target.entity_index);
effectAPI->setEffectXData(_this->CGdEffect, effect_id, EFFECT_DO_NOT_ADD_SUBSPELL, 1);
effectAPI->setEffectXData(_this->CGdEffect, effect_id, EFFECT_PHYSICAL_DAMAGE, damage); kGdEffectNone = 0,
kGdEffectSpellCast = 1,
kGdEffectSpellHitWorld = 2,
kGdEffectSpellHitTarget = 3,
kGdEffectSpellDOTHitTarget = 4,
kGdEffectSpellMissTarget = 5,
kGdEffectSpellResolve = 6,
kGdEffectSummonWorker = 7,
kGdEffectWorkerAppears = 8,
kGdEffectSummonHero = 9,
kGdEffectHeroAppears = 10,
kGdEffectSpellTargetResisted = 11,
kGdEffectSpellResolveSelf = 12,
kGdEffectMeteorFall = 13,
kGdEffectMeteorHit = 14,
kGdEffectBlizzardFall = 15,
kGdEffectBlizzardHit = 16,
kGdEffectStoneFall = 17,
kGdEffectStoneHit = 18,
kGdEffectPetAppears = 19,
kGdEffectTest = 20,
kGdEffectMonumentClaimed = 21,
kGdEffectMonumentWorking = 22,
kGdEffectAuraResolve = 23,
kGdEffectProjectile = 24,
kGdEffectBuilding = 25,
kGdEffectPlayerBind = 26,
kGdEffectSummonMainChar = 27,
kGdEffectMainCharAppears = 28,
kGdEffectTitanProduction = 29,
kGdEffectTitanAppears = 30,
kGdEffectMentalTowerCast = 31,
kGdEffectMentalTowerIdle = 32,
kGdEffectMonumentBullet = 33,
kGdEffectMonumentHitFigure = 34,
kGdEffectSpellAssistanceHitFigure = 35,
kGdEffectChainResolve = 36,
kGdEffectSpellVoodooHitFigure = 37,
kGdEffectSpellManaShieldHitFigure = 38,
kGdEffectMax = 39The spell and effect XData keys are defined within the same enumeration known as SpellDataKey which is stored in sf_general_structures.h. Only the keys relevant for the Effects are listed here.
EFFECT_EFFECT_INDEX = 0x06,
EFFECT_SPELL_INDEX = 0x11,
EFFECT_SPELL_ID = 0x09,
EFFECT_ENTITY_INDEX2 = 0x1A,
EFFECT_SUBSPELL_ID = 0x1C,
EFFECT_PHYSICAL_DAMAGE = 0x1E,
EFFECT_ENTITY_INDEX = 0x2F,
EFFECT_ENTITY_INDEX3 = 0x2D,
EFFECT_ENTITY_TYPE = 0x30,
EFFECT_ENTITY_TYPE2 = 0x13,
EFFECT_DO_NOT_ADD_SUBSPELL = 0x33,