Jump to content

ApplyEffectOnObject problem with custom spells


Recommended Posts

Hello, I have recently started to make my first DA mod. I want to add some custom spells for mages. I am trying to add a sustained ability (currently a modified Shield Defense). The spell works, all buffs are applied correctly, the correct amound of fatigue is added, the character enters the shield defense idle stance and the spell uses the correct custom icon on the hotbar. However, the icon on the status bar that displays active effects is grayed out and has no text on mouse over.
Blank_Icon.jpg

The spell is defined in ABI_base_aw.GDA.

 

The aw_expert.nss script that is executed looks like this:

// -----------------------------------------------------------------------------
// aw_expert.nss
// -----------------------------------------------------------------------------
/*
    Ability Script for Arcane Weaponmaster Shield Expert sustained ability
*/
// -----------------------------------------------------------------------------
// MaxL
// -----------------------------------------------------------------------------

#include "log_h"
#include "abi_templates"
#include "talent_constants_h"
#include "spell_constants_h"
#include "ability_summon_h"
#include "plt_tut_modal"
#include "plt_cod_aow_spellcombo7"
#include "aw_2da_constants_h"

const resource SCRIPT_TALENT_AOE_DURATION = R"talent_aoe_duration.ncs";

// add effects
void _ActivateModalAbility(struct EventSpellScriptImpactStruct stEvent)
{
    // effects
    effect eEffect;
    effect[] eEffects;
    int bPartywide = FALSE;

    if(IsFollower(stEvent.oCaster))
    {
        WR_SetPlotFlag(PLT_TUT_MODAL, TUT_MODAL_1, TRUE);
    }

    float fDefense = 15.0f;

    eEffects[0] = EffectModifyProperty(PROPERTY_ATTRIBUTE_DEFENSE, fDefense);
    eEffects[1] = EffectModifyProperty(PROPERTY_ATTRIBUTE_MISSILE_SHIELD, SHIELD_DEFENSE_MISSILE_SHIELD_BONUS);

    // activation vfx
    Ability_ApplyObjectImpactVFX(stEvent.nAbility, stEvent.oCaster);

    #ifdef DEBUG
    Log_Trace_Spell("_ActivateModalAbility", "Activating modal ability.", stEvent.nAbility, OBJECT_INVALID);
    #endif
    
    Ability_ApplyUpkeepEffects(stEvent.oCaster, stEvent.nAbility, eEffects, stEvent.oTarget, bPartywide);
    
    #ifdef DEBUG
    Log_Trace_Spell("_ActivateModalAbility", "Modal ability activated.", stEvent.nAbility, OBJECT_INVALID);
    #endif
}

// remove effects
void _DeactivateModalAbility(object oCaster, int nAbility)
{
    #ifdef DEBUG
    Log_Trace_Spell("_DeactivateModalAbility", "Deactivate modal ability.", nAbility, OBJECT_INVALID);
    #endif

    // remove effects
    Effects_RemoveUpkeepEffect(oCaster, nAbility);
}

void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);

    switch(nEventType)
    {
        case EVENT_TYPE_SPELLSCRIPT_PENDING:
        {
            // hand through
            Ability_SetSpellscriptPendingEventResult(COMMAND_RESULT_SUCCESS);

            break;
        }

        case EVENT_TYPE_SPELLSCRIPT_CAST:
        {
            // Get a structure with the event parameters
            struct EventSpellScriptCastStruct stEvent = Events_GetEventSpellScriptCastParameters(ev);

            // we just hand this through to cast_impact
            SetAbilityResult(stEvent.oCaster, stEvent.nResistanceCheckResult);

            break;
        }

        case EVENT_TYPE_SPELLSCRIPT_IMPACT:
        {
            // Get a structure with the event parameters
            struct EventSpellScriptImpactStruct stEvent = Events_GetEventSpellScriptImpactParameters(ev);

            #ifdef DEBUG
            Log_Trace(LOG_CHANNEL_COMBAT_ABILITY, GetCurrentScriptName() + ".EVENT_TYPE_SPELLSCRIPT_IMPACT",Log_GetAbilityNameById(stEvent.nAbility));
            #endif

            // Remove any previously existing effects from same spellid to avoid stacking
            Ability_PreventAbilityEffectStacking(stEvent.oTarget, stEvent.oCaster, stEvent.nAbility);

            // activate ability
            _ActivateModalAbility(stEvent);

            break;
        }

        case EVENT_TYPE_SPELLSCRIPT_DEACTIVATE:
        {
            // Get a structure with the event parameters
            struct EventSpellScriptDeactivateStruct stEvent = Events_GetEventSpellScriptDeactivateParameters(ev);

            // is ability active?
            if (IsModalAbilityActive(stEvent.oCaster, stEvent.nAbility) == TRUE)
            {
                _DeactivateModalAbility(stEvent.oCaster, stEvent.nAbility);
            }

            // Setting Return Value (abort means we aborted the ability)
            Ability_SetSpellscriptPendingEventResult(COMMAND_RESULT_INVALID);

            break;
        }
    }
}

I have done some experimentaion with the Ability_ApplyUpkeepEffects method from Bioware's ability_h.nss file. It calls ApplyEffectOnObject from core_h.nss and takes the ability ID as an argument. I guess that the Engine_applyEffectOnObject method that is used as a connection between the user accessible scripts and the engine cannot find the custom ability, even though all previous methods could. When I modify Ability_ApplyUpkeepEffects in ability_h.nss to pass a non-custom ability ID, I get the corresponding icon and text in the status bar.

 

Can anyone help me with this problem? Is there another table that I have to register my custom spells in such that the Engine_applyEffectOnObject method can access the necessary resources?

Edited by unh0lym4g1c14n
Link to comment
Share on other sites

I can't respond in detail because I'm using my tablet at work

 

Your code is probably fine, you just need to add new strings through the string editor and then add them to the gda. I suggest going to the toolset wiki, search on 'adding a new spell' and an example should should show up. You already have the hard part done.

Link to comment
Share on other sites

I can't respond in detail because I'm using my tablet at work

 

Your code is probably fine, you just need to add new strings through the string editor and then add them to the gda. I suggest going to the toolset wiki, search on 'adding a new spell' and an example should should show up. You already have the hard part done.

Thank you for your reply. I have already added the corresponding strings. Here is an picture of my gda and my defined strings:

 

Tables.png

I used the 'adding a new spell' tutorial to create my spells. I exported the talk table and the strings are displayed correctly when you look at the skill on your hotbar or in the talent/spell overview. The only thing missing is the icon and description in the effects bar. When i modify my Arcane Bash spell to target the caster, the applied effect (which should be the normal shield bash icon) is also not displayed. That means the problem is not limited to effects generated by sustained abilities but extends to all effects applied by my custom spells.

Link to comment
Share on other sites

the name of the icon goes (GDA) in the icon column (no file extension), of course, the icon must exist

namestrref, descstrref, tooltipstrref, and strid_effect should hall of strings associated with them.

 

My most common mistake is to have a space after the number or string.

Link to comment
Share on other sites

Did you add the icon to the gda?

 

The issue is with the gda or string. I know I never had to add to do anything in the scripts

The icon is added and (just like all other strings) is displayed correctly everywhere except for the status bar.

 

the name of the icon goes (GDA) in the icon column (no file extension), of course, the icon must exist

namestrref, descstrref, tooltipstrref, and strid_effect should hall of strings associated with them.

 

My most common mistake is to have a space after the number or string.

 

I double checked my strings, tried biowares strings instead of my own.

I uploaded my ABI_base_aw.xml, the corresponding GDA and my script for the Shield Expert ability: https://ufile.io/5d8b3

In the ABI_base.xml files, there are multiple tables. Do I have to add something to the ability_data or ability_effects subtables? Apart from that, I am running out of ideas :(

I have tried out the Spell School - Divine mod (www.nexusmods.com/dragonage/mods/703/?) and all effects from that mod are displayed correctly. I inspected its GDAs and they look the same as mine do. The scripts are only available in the unreadable ncs format so i can't check those.

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...