Author Topic: Need a fix for a default feat-determined loot spawning script  (Read 652 times)

Legacy_HipMaestro

  • Hero Member
  • *****
  • Posts: 2849
  • Karma: +0/-0
Need a fix for a default feat-determined loot spawning script
« on: January 20, 2012, 04:01:39 pm »


               The situation
A container in the OC Chapter1 module uses nw_o2_feat.nss to generate a weapon based on a PC's weapon focus feats. 

The problem
Occasionally (somewhere around 1 out 8-10 times or so) this script produces nothing.

The condition
In this case, there are 2 weapon foci for the PC, specifically WF: rapier & WF: sling.  The script will seed a rapier correctly, but never a sling.  I suspect that where a sling SHOULD be getting spawned is the point where an empty container results.  There IS a section dedicated to WF: sling within the current script, so assuming that WF: sling is the only focus, it should spawn properly.

I have not checked the Include.  Perhaps something is being set in there that impacts this function of the seeding script?  Dunno, but I doubt it.

The request
I would like to apply a general fix that overwrites this one so that multiple weapon focus PCs will be afforded equal chances of getting either weapon spawned.  (I have done a little scripting myself... the emphasis on the qualifier "little"... so would probably do more damage than good with these fingers.)

If this issue has already been addressed, please furnish a link to the resource.

Thanks, in advance, team! '<img'>
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Need a fix for a default feat-determined loot spawning script
« Reply #1 on: January 20, 2012, 04:09:34 pm »


               can you send me saved game? will speed up the process '<img'>
               
               

               
            

Legacy_HipMaestro

  • Hero Member
  • *****
  • Posts: 2849
  • Karma: +0/-0
Need a fix for a default feat-determined loot spawning script
« Reply #2 on: January 20, 2012, 05:02:21 pm »


               

ShaDoOoW wrote...
can you send me saved game? will speed up the process '<img'>

Sure can.  Email?  (You can PM an addy if you prefer.)

edit: Sent save.
               
               

               


                     Modifié par HipMaestro, 20 janvier 2012 - 05:59 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Need a fix for a default feat-determined loot spawning script
« Reply #3 on: January 22, 2012, 01:02:25 pm »


               So I finally looked into this. It has othing to do with sling because the default script doesn't work with multiple WFs. Since rapier check is before sling, script will always try to create rapier. However there is in script nonexistant rapier resref so thats why you occasionally get nothing.

There are two ways how to fix it:
- create new rapier with given resref (but dont you dare to say fix to this or peoples get mad lol)
- remove the resref from script

for second solution there is modified function in nw_o2_feat :

void CreateRapier(object oTarget, object oAdventurer)
{

       string sItem = "";
       int nHD = GetHitDice(oAdventurer);

       if (GetRange(1, nHD))    // * 800
       {
                 int nRandom = Random(1) + 1;
                 switch (nRandom)
                 {
                      case 1: sItem = "nw_wswmrp002"; break;
                  }

       }
       else if (GetRange(2, nHD))   // * 200 - 2500
       {
                 int nRandom = Random(1) + 1;
                 switch (nRandom)
                 {
                      case 1: sItem = "nw_wswmrp002"; break;
                  }

       }
       else if (GetRange(3, nHD))   // * 800 - 10000
       {
                 int nRandom = Random(3) + 1;
                 switch (nRandom)
                 {
                      case 1: sItem = "nw_wswmrp002"; break;
                      case 2: sItem = "nw_wswmrp004"; break;
                      case 3: sItem = "nw_wswmrp010"; break;
//non-existant                      case 4: sItem = "nw_wswmrp003"; break;
                  }

       }
       else if (GetRange(4, nHD))   // * 2500 - 16500
       {
                 int nRandom = Random(3) + 1;
                 switch (nRandom)
                 {
                      case 1: sItem = "nw_wswmrp004"; break;
                      case 2: sItem = "nw_wswmrp010"; break;
                      case 3: sItem = "nw_wswmrp005"; break;
//non-existant                       case 4: sItem = "nw_wswmrp003"; break;
                  }

       }
       else if (GetRange(5, nHD))   // * 8000 - 25000
       {
                 int nRandom = Random(3) + 1;
                 switch (nRandom)
                 {
                      case 1: sItem = "nw_wswmrp005"; break;
                      case 2: sItem = "nw_wswmrp011"; break;
                      case 3: sItem = "nw_wswmrp007"; break;
//non-existant                       case 1: sItem = "nw_wswmrp003"; break;
                  }

       }
       else if (GetRange(6, nHD))   // * 16000 and up
       {
                 int nRandom = Random(3) + 1;
                 switch (nRandom)
                 {
                      case 1: sItem = "nw_wswmrp011"; break;
                      case 2: sItem = "nw_wswmrp007"; break;
                      case 3: sItem = "nw_wswmrp006"; break;
                  }

       }
       if (sItem != "")
         dbCreateItemOnObject(sItem, oTarget, 1);
}


But I will try to enable multifocus support so keep tuned.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Need a fix for a default feat-determined loot spawning script
« Reply #4 on: January 22, 2012, 07:44:16 pm »


               UPDATE

I finished it, this is what I have done:

- non-existant resref for rapier changed to create Namarra +1
- not only weapon focus is taken into account, improved critical also matter
- added support for character with multiple weapon focuses - script generate random focused weapon in this case
- barbarians without any weapon feat gets great axe instead of club
- improved weapon selection for multiclassed characters without weapon feats:
 - when previously ranger9/druid1 get druidic weapon now gets longsword like pure ranger etc.
- custom base class without any weapon feat gets dagger instead of nothing
- added support for weapons from expansions/patches (dwarven waraxe, whip, trident)


DOWNLOAD (erf inside zip)

however untested, there might be new bugs caused by my code, in that case lmk
               
               

               


                     Modifié par ShaDoOoW, 22 janvier 2012 - 07:45 .
                     
                  


            

Legacy_HipMaestro

  • Hero Member
  • *****
  • Posts: 2849
  • Karma: +0/-0
Need a fix for a default feat-determined loot spawning script
« Reply #5 on: February 11, 2012, 04:32:10 pm »


               

ShaDoOoW wrote...

UPDATE

I finished it, this is what I have done:

- non-existant resref for rapier changed to create Namarra +1
- not only weapon focus is taken into account, improved critical also matter
- added support for character with multiple weapon focuses - script generate random focused weapon in this case
- barbarians without any weapon feat gets great axe instead of club
- improved weapon selection for multiclassed characters without weapon feats:
 - when previously ranger9/druid1 get druidic weapon now gets longsword like pure ranger etc.
- custom base class without any weapon feat gets dagger instead of nothing
- added support for weapons from expansions/patches (dwarven waraxe, whip, trident)


DOWNLOAD (erf inside zip)

however untested, there might be new bugs caused by my code, in that case lmk

Apologies for my late reply, ShaDoOoW.

I had been expecting a fix notification via email so had missed your work posted here. Good thing I rechecked because topics tend to move down quickly in the scripting forum.  '<img'>

At any rate... thanks for investigating this issue and resolving it.  I would have never suspected there was anything that unique about rapiers.  The other fixes will be handy as well.  As usual, nice work, amigo! 

edit: Hmmm... when I click on the DOWNLOAD link all I get is "404 Not Found".  Did I miss my chance to grab it being late like this?
               
               

               


                     Modifié par HipMaestro, 11 février 2012 - 04:38 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Need a fix for a default feat-determined loot spawning script
« Reply #6 on: February 11, 2012, 05:09:26 pm »


               well I included it in the patch 1.71 beta release so I removed standalone script as I thought you downloaded it already

I guess I can reupload the standalone script if you have reasons not to use my unofficial patch, lmk in that case