Jump to content

New spell doesn't do damage


Lear19

Recommended Posts

So I was trying to copy-paste Fireball spell, so that I can change its cost and cooldown without changing it for everyone else in game and then use it with 'shapeshifting into an Arcane Horror' mod, but it has no effect, it deals no damage, it basically just has an animation of blowing up, but that's it, no damage, no knockback, etc. I modifiedonly the ID, so it's different from the 10003 and I don't know what to do now. Any help?

Edited by Lear19
Link to comment
Share on other sites

From what you've said, I'm guessing what you've done is making a duplicate of the Fireball entry in the abi table, then giving the new entry a different ID? If so, then your new spell won't do anything because its designated script is still spell_aoe_instant.ncs as per the abi table, but this script has no implementation for your custom spell.

 

Inside each ability script, there are codes dedicated to individual abilities that dictate what the abilities do. If you make custom abilities, you need to create the corresponding code (optionally custom scripts as well) for your spells.

 

So let's say you're trying to duplicate Fireball. After creating a new entry in the abi table, you'd want to duplicate the code for Fireball (which can be found in spell_aoe_instant.nss, then change the ID of this new code from ABILITY_SPELL_FIREBALL (as it appears in the source code) to your custom ID. You can put your new code in the existing script, taking advatange of the existing code structure, or you can make your own script.

Link to comment
Share on other sites

From what you've said, I'm guessing what you've done is making a duplicate of the Fireball entry in the abi table, then giving the new entry a different ID? If so, then your new spell won't do anything because its designated script is still spell_aoe_instant.ncs as per the abi table, but this script has no implementation for your custom spell.

 

Inside each ability script, there are codes dedicated to individual abilities that dictate what the abilities do. If you make custom abilities, you need to create the corresponding code (optionally custom scripts as well) for your spells.

 

So let's say you're trying to duplicate Fireball. After creating a new entry in the abi table, you'd want to duplicate the code for Fireball (which can be found in spell_aoe_instant.nss, then change the ID of this new code from ABILITY_SPELL_FIREBALL (as it appears in the source code) to your custom ID. You can put your new code in the existing script, taking advatange of the existing code structure, or you can make your own script.

Ah, so it requires the Toolset, because I don't think there's any other way to edit nss files. That's a bummer, but thank you for answer.

Link to comment
Share on other sites

From what you've said, I'm guessing what you've done is making a duplicate of the Fireball entry in the abi table, then giving the new entry a different ID? If so, then your new spell won't do anything because its designated script is still spell_aoe_instant.ncs as per the abi table, but this script has no implementation for your custom spell.

 

Inside each ability script, there are codes dedicated to individual abilities that dictate what the abilities do. If you make custom abilities, you need to create the corresponding code (optionally custom scripts as well) for your spells.

 

So let's say you're trying to duplicate Fireball. After creating a new entry in the abi table, you'd want to duplicate the code for Fireball (which can be found in spell_aoe_instant.nss, then change the ID of this new code from ABILITY_SPELL_FIREBALL (as it appears in the source code) to your custom ID. You can put your new code in the existing script, taking advatange of the existing code structure, or you can make your own script.

So, for the first time in my life, I managed to get Toolset to work without errors, but I have a question about what I'm supposed to do.

 

I found the spell_aoe_instant.nss and the Fireball spell, I copied its code and changed "ABILITY_SPELL_FIREBALL" to "ABILITY_SPELL_FIREBALL_2" but how do I edit it in my abi_base.gda to link that new code to it? In spell_aoe_instant.nss I did not find the ID typical for Fireball spell "10003" and in abi_base.gda I didn't find "ABILITY_SPELL_FIREBALL". How does the game know that these two are linked?

Link to comment
Share on other sites

They are linked via the header script 2da_constants_h. This is a header file (meaning that it's not actually executed by the game and you don't compile it) that contains all the ability IDs in the game, and the declarations where these IDs are given representative names. This file is "imported" into spell_aoe_instant via the "#include" commands at the top of the script. spell_aoe_instant includes abi_templates, which in turns includes 2da_constants_h. By this link the game knows that when you type "ABILITY_SPELL_FIREBALL", it's supposed to read that as "10003".

 

If you rightclick ABILITY_SPELL_FIREBALL in spell_aoe_instant, and select "Go to definition", it'll take you to where that name is declared.

 

You can simply use the IDs directly, such as 10003 for Fireball, and so on. The custom names are just so we can more easily understand the source code.

 

So when making a custom spell, once you've made a custom spell entry in the abi table and given it a unique ID, you can use that ID directly in the ability scripts. If you want to give it a representative name, such as ABILITY_SPELL_FIREBALL_2, you have to declare this somewhere - either in 2da_constants_h (in which case you may want to save the file), or right in the file spell_aoe_constants.nss, by writing it like this

 

const int ABILITY_SPELL_FIREBALL_2 = 250000;

 

and put that line at the top of the script. spell_aoe_instant already has a similar declaration "const int MAX_AOE_TARGETS = 30;", so you can put your declaration next to it. For one simple custom spell I think it's fine to do this. But for a larger scale mod you may want to be more structured and put all custom name declarations somewhere else, such as 2da_constants_h.

Link to comment
Share on other sites

They are linked via the header script 2da_constants_h. This is a header file (meaning that it's not actually executed by the game and you don't compile it) that contains all the ability IDs in the game, and the declarations where these IDs are given representative names. This file is "imported" into spell_aoe_instant via the "#include" commands at the top of the script. spell_aoe_instant includes abi_templates, which in turns includes 2da_constants_h. By this link the game knows that when you type "ABILITY_SPELL_FIREBALL", it's supposed to read that as "10003".

 

If you rightclick ABILITY_SPELL_FIREBALL in spell_aoe_instant, and select "Go to definition", it'll take you to where that name is declared.

 

You can simply use the IDs directly, such as 10003 for Fireball, and so on. The custom names are just so we can more easily understand the source code.

 

So when making a custom spell, once you've made a custom spell entry in the abi table and given it a unique ID, you can use that ID directly in the ability scripts. If you want to give it a representative name, such as ABILITY_SPELL_FIREBALL_2, you have to declare this somewhere - either in 2da_constants_h (in which case you may want to save the file), or right in the file spell_aoe_constants.nss, by writing it like this

 

const int ABILITY_SPELL_FIREBALL_2 = 250000;

 

and put that line at the top of the script. spell_aoe_instant already has a similar declaration "const int MAX_AOE_TARGETS = 30;", so you can put your declaration next to it. For one simple custom spell I think it's fine to do this. But for a larger scale mod you may want to be more structured and put all custom name declarations somewhere else, such as 2da_constants_h.

 

Hmm... so I choose the simpler way and just placed the ID in the duplicated codes. It actually worked, as now the spell has the name and description of a Fireball in-game (it was blank before) but weirdly enough, it still doesn't do damage and has no knockback or burning effect...

 

The code looks like this:

case ABILITY_SPELL_FIREBALL:
        {
            float fDamage = (100.0f + GetCreatureSpellPower(stEvent.oCaster)) * FIREBALL_DAMAGE_FACTOR;

            // damage over time
            ApplyEffectDamageOverTime(oTarget, stEvent.oCaster, stEvent.nAbility, fDamage, FIREBALL_DURATION, DAMAGE_TYPE_FIRE);

            // impact damage
            eEffect = EffectDamage(fDamage, DAMAGE_TYPE_FIRE);
            ApplyEffectOnObject(EFFECT_DURATION_TYPE_INSTANT, eEffect, oTarget, 0.0f, stEvent.oCaster, stEvent.nAbility);

            // physical resistance
            if (ResistanceCheck(stEvent.oCaster, oTarget, PROPERTY_ATTRIBUTE_SPELLPOWER, RESISTANCE_PHYSICAL) == FALSE)
            {
                // knockdown
                eEffect = EffectKnockdown(oTarget, 0, stEvent.nAbility);
                eEffect = SetEffectEngineInteger(eEffect, EFFECT_INTEGER_USE_INTERPOLATION_ANGLE, 2);
                eEffect = SetEffectEngineVector(eEffect, EFFECT_VECTOR_ORIGIN, GetPositionFromLocation(stEvent.lTarget));
                ApplyEffectOnObject(EFFECT_DURATION_TYPE_TEMPORARY, eEffect, oTarget, RandomFloat(), stEvent.oCaster, stEvent.nAbility);
            }

            break;
        }
        
case 250000:
        {
            float fDamage = (100.0f + GetCreatureSpellPower(stEvent.oCaster)) * FIREBALL_DAMAGE_FACTOR;

            // damage over time
            ApplyEffectDamageOverTime(oTarget, stEvent.oCaster, stEvent.nAbility, fDamage, FIREBALL_DURATION, DAMAGE_TYPE_FIRE);

            // impact damage
            eEffect = EffectDamage(fDamage, DAMAGE_TYPE_FIRE);
            ApplyEffectOnObject(EFFECT_DURATION_TYPE_INSTANT, eEffect, oTarget, 0.0f, stEvent.oCaster, stEvent.nAbility);

            // physical resistance
            if (ResistanceCheck(stEvent.oCaster, oTarget, PROPERTY_ATTRIBUTE_SPELLPOWER, RESISTANCE_PHYSICAL) == FALSE)
            {
                // knockdown
                eEffect = EffectKnockdown(oTarget, 0, stEvent.nAbility);
                eEffect = SetEffectEngineInteger(eEffect, EFFECT_INTEGER_USE_INTERPOLATION_ANGLE, 2);
                eEffect = SetEffectEngineVector(eEffect, EFFECT_VECTOR_ORIGIN, GetPositionFromLocation(stEvent.lTarget));
                ApplyEffectOnObject(EFFECT_DURATION_TYPE_TEMPORARY, eEffect, oTarget, RandomFloat(), stEvent.oCaster, stEvent.nAbility);
            }

            break;
        }
        // spell-specific special events
        switch (stEvent.nAbility)
        {
            case ABILITY_SPELL_FIREBALL:
            {
                // ignite
                SendComboEventAoE(COMBO_EVENT_IGNITE, SHAPE_SPHERE, stEvent.lTarget, stEvent.oCaster, fRadius);

                break;
            }  
            
            case 250000:
            {
                // ignite
                SendComboEventAoE(COMBO_EVENT_IGNITE, SHAPE_SPHERE, stEvent.lTarget, stEvent.oCaster, fRadius);

                break;
            }

Am I missing something?

 

My guess would be that I'm messing something with exporting? I used the option Tools / Export / Export with dependent resources...

Link to comment
Share on other sites

My guess would be that I'm messing something with exporting? I used the option Tools / Export / Export with dependent resources...

Maybe, because the code seems to be fine. (I'm assuming you have checked out the source code in the Toolset; there should be a green check mark next to it in the Palette Window to the right) After making your changes to spell_aoe_instant.nss in the toolset, you just save it - right-click the spell_aoe_instant.nss tab in the main window, select "Save" - this will compile the script and if that is successful the source code will be saved. After that, you should have a file called spell_aoe_instant.NCS (along with the NSS which is a text file you can view with any text editor) in a folder called toolsetexport in your Override folder (this is the modified script that the Toolset has just exported). This should be enough for the changes to apply.

 

Also, for your custom spell to have the proper name, description, icon, and so on, in the game, this only has to do with the abi table; it has nothing to do with the script.

Edited by DLuf
Link to comment
Share on other sites

 

 

I'm assuming you have checked out the source code in the Toolset; there should be a green check mark next to it in the Palette Window to the right

 

I have a check mark like that. It showed up after I saved a local copy.

 

P87rEBN.png

 

 

After making your changes to spell_aoe_instant.nss in the toolset, you just save it - right-click the spell_aoe_instant.nss tab in the main window, select "Save" - this will compile the script and if that is successful the source code will be saved. After that, you should have a file called spell_aoe_instant.NCS (along with the NSS which is a text file you can view with any text editor) in a folder called toolsetexport in your Override folder (this is the modified script that the Toolset has just exported). This should be enough for the changes to apply.

 

So I did it that way, I checked the .nss and the changes are there, so I copied the .ncs file into my Override folder, alongside my abi_base.gda which looks like this:

 

PlMlZ74.png

 

But unfortunately it still has no in-game effect...

 

I checked also in a new game, becuse I wasn't sure if it would apply to the saved one. Oh, and I also threw away all other mods from the Override folder as I wasn't sure if one of the files weren't using the same script (Dain's fixes used the file named spell_aoe_instant.NCS, for example) but that didn't help either...

Link to comment
Share on other sites

  • Recently Browsing   0 members

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