Author Topic: Help with Custom Weapons  (Read 351 times)

Legacy_TheGmork

  • Jr. Member
  • **
  • Posts: 60
  • Karma: +0/-0
Help with Custom Weapons
« on: May 11, 2012, 02:17:57 pm »


               Alright, firstly I have made 2 weapons
that are out side the standard base items. They are:

A Pike
A Greatmace

They are represented in my hak baseitems.2da like
this:

         
         Name            Label

151   16777217     pike
152   16777222     greatmace

The first thing I
want to do is add them to x2_i0_spells and x2_inc_itemprop in the GetMeleeWeapon and the IPGetIsMeleeWeapon functions. However I am not a good scriptor and my attempts failed '<img'> I asked a few people who are scriptors but they were not sure how to do it either.

So, could some one help me with how to add them in to those functions please?

Secondly I want both weapons to work with feats like Weapon Focus, Weapon Specialization, Improved Crit ect. But I have no idea which files I need to edit to get those to work like that (or even if it is possible). Any help I could get would be appreciated.

Cheers.
               
               

               


                     Modifié par TheGmork, 11 mai 2012 - 01:20 .
                     
                  


            

Legacy__six

  • Hero Member
  • *****
  • Posts: 1436
  • Karma: +0/-0
Help with Custom Weapons
« Reply #1 on: May 11, 2012, 02:37:27 pm »


               

TheGmork wrote...

Secondly I want both weapons to work with feats like Weapon Focus, Weapon Specialization, Improved Crit ect. But I have no idea which files I need to edit to get those to work like that (or even if it is possible). Any help I could get would be appreciated.

These are unfortunately pretty much impossible, as those feats are hardcoded within the engine to weapons on specific 2da lines. You can add the feats but they won't actually have any effect. Although I seem to recall it might be possible to implement using NWNX, so it depends what you're creating the weapons for whether that's an option.
               
               

               


                     Modifié par _six, 11 mai 2012 - 01:37 .
                     
                  


            

Legacy_Daijin

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
Help with Custom Weapons
« Reply #2 on: May 11, 2012, 08:20:34 pm »


               _six is talking about nwnx_cool i think.   I use it to give cep and other weapons useable feats already put in by bioware.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Help with Custom Weapons
« Reply #3 on: May 11, 2012, 08:40:38 pm »


               

TheGmork wrote...


Alright, firstly I have made 2 weapons
that are out side the standard base items. They are:

A Pike
A Greatmace

They are represented in my hak baseitems.2da like
this:

         
         Name            Label

151   16777217     pike
152   16777222     greatmace

The first thing I
want to do is add them to x2_i0_spells and x2_inc_itemprop in the GetMeleeWeapon and the IPGetIsMeleeWeapon functions. However I am not a good scriptor and my attempts failed '<img'> I asked a few people who are scriptors but they were not sure how to do it either.

This is already done in community Patch. If you decide to give it a try, don't worry about latest version is beta. It has been tested and Im still aroun there in case any troubles - which noone reported so far.
               
               

               
            

Legacy_Carcerian

  • Hero Member
  • *****
  • Posts: 1655
  • Karma: +0/-0
Help with Custom Weapons
« Reply #4 on: May 13, 2012, 05:42:04 am »


               Yup the funtion you are looking for is IPGetIsMeleeWeapon(), found in x2_inc_itemprop.nss,

search for "int IPGetIsMeleeWeapon(object oItem)"

heres an example of a CEP + 169 one:

int IPGetIsMeleeWeapon(object oItem)
{
    int nItemType = GetBaseItemType(oItem);
    if ( nItemType < 300 )
        // BioWare weapons.
        switch ( nItemType )
        {
            case BASE_ITEM_BASTARDSWORD:
            case BASE_ITEM_BATTLEAXE:
            case BASE_ITEM_CLUB:
            case BASE_ITEM_DAGGER:
            case BASE_ITEM_DIREMACE:
            case BASE_ITEM_DOUBLEAXE:
            case BASE_ITEM_DWARVENWARAXE:
            case BASE_ITEM_GREATAXE:
            case BASE_ITEM_GREATSWORD:
            case BASE_ITEM_HALBERD:
            case BASE_ITEM_HANDAXE:
            case BASE_ITEM_HEAVYFLAIL:
            case BASE_ITEM_KAMA:
            case BASE_ITEM_KATANA:
            case BASE_ITEM_KUKRI:
            case BASE_ITEM_LIGHTFLAIL:
            case BASE_ITEM_LIGHTHAMMER:
            case BASE_ITEM_LIGHTMACE:
            case BASE_ITEM_LONGSWORD:
            case BASE_ITEM_MAGICSTAFF:
            case BASE_ITEM_MORNINGSTAR:
            case BASE_ITEM_QUARTERSTAFF:
            case BASE_ITEM_RAPIER:
            case BASE_ITEM_SCIMITAR:
            case BASE_ITEM_SCYTHE:
            case BASE_ITEM_SHORTSPEAR:
            case BASE_ITEM_SHORTSWORD:
            case BASE_ITEM_SICKLE:
            case BASE_ITEM_TRIDENT:
            case BASE_ITEM_TWOBLADEDSWORD:
            case BASE_ITEM_WARHAMMER:
            case BASE_ITEM_WHIP:

// Gloves!!!
            case BASE_ITEM_GLOVES:

//169 Additions
            case 92: // Lance
            case 93: // Moon-on-a-stick
            case 94: // Trumpet

            return TRUE;
        }
    else
        // CEP weapons.
        switch ( nItemType )
        {
            // CEP Tiny Spear
            case 210: // Tiny Spear

            // CEP Flowers
            case 325: // Flowers
            case 327: // Crystal Flowers

            case 300: // CEP trident
            case 301: // heavy pick
            case 302: // light pick
            case 303: // sai
            case 304: // nunchaku
            case 305: // falchion
            case 308: // sap
            case 309: // assassin dagger
            case 310: // katar
            case 312: // mace2
            case 313: // kukri2
            case 314: // fashion accessory
            case 316: // falchion2
            case 317: // heavy mace
            case 318: // maul
            case 319: // mercurial longsword
            case 320: // mercurial greatsword
            case 321: // double scimitar
            case 322: // goad
            case 323: // wind-fire wheel
            case 324: // maug double sword
            case 330: // longsword2

            //CEP 2.3 Gloves
            case 376: // Gloves, Spiked
            case 377: // Gloves, Bladed

            return TRUE;
        }

    // Default: not a melee weapon.
    return FALSE;
}


be sure to recompile all scripts at least twice, as this one is used for magic weapon and other weapon effect spell validation.

you want to make one that looks something like this:

int IPGetIsMeleeWeapon(object oItem)
{
    int nItemType = GetBaseItemType(oItem);
    if ( nItemType < 300 )
        switch ( nItemType )
        {
      // New Custom Content
            case 151: // New Pike
            case 152: // New Great Mace

        // BioWare weapons.
            case BASE_ITEM_BATTLEAXE:
            case BASE_ITEM_BASTARDSWORD:
            case BASE_ITEM_BATTLEAXE:
            case BASE_ITEM_CLUB:
            case BASE_ITEM_DAGGER:
            case BASE_ITEM_DIREMACE:
            case BASE_ITEM_DOUBLEAXE:
            case BASE_ITEM_DWARVENWARAXE:
            case BASE_ITEM_GREATAXE:
            case BASE_ITEM_GREATSWORD:
            case BASE_ITEM_HALBERD:
            case BASE_ITEM_HANDAXE:
            case BASE_ITEM_HEAVYFLAIL:
            case BASE_ITEM_KAMA:
            case BASE_ITEM_KATANA:
            case BASE_ITEM_KUKRI:
            case BASE_ITEM_LIGHTFLAIL:
            case BASE_ITEM_LIGHTHAMMER:
            case BASE_ITEM_LIGHTMACE:
            case BASE_ITEM_LONGSWORD:
            case BASE_ITEM_MAGICSTAFF:
            case BASE_ITEM_MORNINGSTAR:
            case BASE_ITEM_QUARTERSTAFF:
            case BASE_ITEM_RAPIER:
            case BASE_ITEM_SCIMITAR:
            case BASE_ITEM_SCYTHE:
            case BASE_ITEM_SHORTSPEAR:
            case BASE_ITEM_SHORTSWORD:
            case BASE_ITEM_SICKLE:
            case BASE_ITEM_TRIDENT:
            case BASE_ITEM_TWOBLADEDSWORD:
            case BASE_ITEM_WARHAMMER:
            case BASE_ITEM_WHIP:

// Monk Gloves!!! - added by Carcerian
            case BASE_ITEM_GLOVES:

//169 Additions - added by Carcerian
            case 92: // Lance
            case 93: // Moon-on-a-stick
            case 94: // Trumpet

            return TRUE;
        }
     // Default: not a melee weapon.
    return FALSE;
}


(add cep stuff if needed...)
               
               

               


                     Modifié par Carcerian, 13 mai 2012 - 05:13 .
                     
                  


            

Legacy_TheGmork

  • Jr. Member
  • **
  • Posts: 60
  • Karma: +0/-0
Help with Custom Weapons
« Reply #5 on: May 14, 2012, 06:22:18 am »


               Thank you all for your help '<img'> Six, I'll look into the NWNX stuff.

ShaDoOoW, we are going to look at putting the patch onto our server.

Carcerian, thank you so much. I'll try that script '<img'>
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Help with Custom Weapons
« Reply #6 on: May 14, 2012, 04:49:28 pm »


               

TheGmork wrote...

Thank you all for your help '<img'> Six, I'll look into the NWNX stuff.

ShaDoOoW, we are going to look at putting the patch onto our server.

Carcerian, thank you so much. I'll try that script '<img'>

If you needed any help with that I will help you - PM me or ask in the community patch discussion thread.

The Community Patch is real booster for newly created (or minimally modified) modules but quite hard to use for existing PW modules with lots of custom changes into spells/2das. At least if you want to have everything merged with the Patch properly (which is not needed).

For the 2DA merging, inside Patch is 3rd party tool called Auto 2DA Merger which will apply all changes from Patch onto your 2DAs. For spell scripts, the best way is to rebuild them onto Patch (that is - remeber how you changed the spell, delete the spellscript, open the spellscript from game default resources, make your changes into spell again in the version from Patch - you will rocognize it easily as all spellscripts uses struct based engine). For the other scripts and includes I suggest to use 3rd party tool called Beyond Compare. Version 2 is shareware. Its a gift for heaven I work with it every day allows you to compare file against file or even two folders.
               
               

               


                     Modifié par ShaDoOoW, 15 mai 2012 - 06:20 .