Author Topic: Tips and tricks in toolset  (Read 515 times)

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Tips and tricks in toolset
« on: February 11, 2012, 01:22:03 pm »


               Since I don't longer believe I will be able to finish my module anymore, I decided I will release my unique(?) knowhow gathered from many years of bulding and playing NWN. Would be nice to mention me if you decide to spread these knowhow on yours site or NWN Wiki.

OnDamaged event for player characters
- add OnHitCastSpell: unique power (or create custom spell that you replace the unique power with) on armor when equipped and remove this properta when unequipped, each time anyone hit PC, the spellscript of this spell will run, for onhit unique power it is: X2_S3_OnHitCast
- for situation when PC has no armor, use either skin with this OnHit (OnHit on skin is called only when PC has no armor) or force player to equip custom armor that has same appearance as being naked
- the script is called *before* damage is done, OnDamaged event functions will not work yet, but delaying the script by 0.01sec will catch the right moment where functions GetTotalDamageDealth or GetLastDamager works
- damage can be avoided via setting plot flag on PC before damage and removing the plot flag after, other approaches doesn't work (if you know different approach please tell)
- FunkySwerve warned that this method of catching OnDamaged event is not reliable, as far as I can tell, it works reliable for normal environments, the issues start only in environments where PC is subject to too many hits per second not sure how many, but in my testing with it worked always correctly
- unlike monster OnDamaged, damage shield effects won't trigger this script, to do this you have to check whether GetLastDamager is PC and whether OBJECT_SELF has these effects and then run the scripr manually, the same have to be done in general monster OnDamaged event
- unlike monster OnDamaged, spells doesnt trigger this event as well, to do this you need to hook ApplyEffectToObject function (could make example if someone wants to know)

OnLevelDown event
Replace all SetXP and GiveXPToCreature calls with custom function that does this:

void _SetXP(object oCreature, int nXpAmount)
{
int preLevel = GetHitDice(oCreature);
SetXP(oCreature,nXpAmount);
int postLevel = GetHitDice(oCreature);
 if(preLevel > postLevel)
 {
 ExecuteScript("onleveldown",oCreature);
 }
}

With a little modification you could make even OnPreLevelDown event, but I haven't found any purpose for that. In the script OBJECT_SELF if player character that gets deleveled, if you modify the function above, you could also set PC level before delevel and retrieve it via local variable.
- core function hooking is useable here, though number of scripts altering XP is generaly not too high to replace all calls manually

Setting item charges above 50 without NWNX
Neither toolset or nwscript can set charges above 50 limit, however it can be workarounded via editing the item in question via GFF editor. Find the item by its resref in NWN/modules/temp0, open it in GFF editor, change field Charges and save. Note that everytime you edit this item in toolset again, charges are restored to 50. The same goes for nwscript function that cannot setcharges above 50 not even if the item in question has more charges.

The same trick can be done to set arrows stack above 99, without need to modifying baseitems.2da, throwing weapons above 50etc. However note that you cannot use CreateItemOnObject or CreateObject functions as those need to specify stacksize and nwscript functions cannot set more than maximal values defined in baseitems. If you need to spawn these items via script you have to place these items into some container in game and then copy them where you need. It does work well with default NWN treasure generation as this uses CopyObject.

Tileset extensions - new variations without hak
- can be done via GFF editor as well, though very difficult to do, someone else write about this an article, when I found I pu link as well

Another GFF editor tricks
You can modify creature stats above toolset limit of 100 etc. This has the same disadvantage that these changes are lost whenever you edit the creature in toolset, but it works. Also note that AB has certain limit where the AB reroll into negative numbers, however it seems to work fine as it was correct number. (confirmation needed, I havent done too many test of this)

Core function hooking
A knowhow copied from George Zoeller and little modified for specific purpose, however original page seems to no longer exists. (if so I put link instead my version, lmk)
               
               

               


                     Modifié par ShaDoOoW, 12 février 2012 - 01:26 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Tips and tricks in toolset
« Reply #1 on: February 12, 2012, 02:17:51 am »


               IIRC pc ondamaged only fires for first hit in each flurry. Nonissue unless you have critters swinging more than 3x per round at you.

Why don't you think you can finsih your mod anymore? :/

Funky
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Tips and tricks in toolset
« Reply #2 on: February 12, 2012, 01:23:35 pm »


               

FunkySwerve wrote...

IIRC pc ondamaged only fires for first hit in each flurry. Nonissue unless you have critters swinging more than 3x per round at you.

Funky

re-checked - negative

1.69, windows 32bit, without NWNX, triggers for each hit, tested with 40HD ranger with bow, haste and rapid, each from six attacks triggered this script

+ got more info, setting plot flag before damage is possible (and then removing the plot flag after), however other approach like DR itemproperty on item doesnt work, possibly because the adding itemproperty takes the milisecond and damage is applied before
also, the delay works yet since 0.01sec

I will add these informations into article

Why don't you think you can finsih your mod anymore? :/

well... long story short, im not even sure ill be on these forums anymore
               
               

               


                     Modifié par ShaDoOoW, 12 février 2012 - 01:28 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Tips and tricks in toolset
« Reply #3 on: February 16, 2012, 03:09:24 am »


               

ShaDoOoW wrote...

FunkySwerve wrote...

IIRC pc ondamaged only fires for first hit in each flurry. Nonissue unless you have critters swinging more than 3x per round at you.

Funky

re-checked - negative

1.69, windows 32bit, without NWNX, triggers for each hit, tested with 40HD ranger with bow, haste and rapid, each from six attacks triggered this script


On-Hit: cast spell properties do fire for each hit, I am not sure if the delay for damage catching might catch the last hit in the flurry multiple times, given that all attacks in a flurry occur near simultaneously.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Tips and tricks in toolset
« Reply #4 on: February 16, 2012, 07:24:11 pm »


               

WhiZard wrote...
On-Hit: cast spell properties do fire for each hit, I am not sure if the delay for damage catching might catch the last hit in the flurry multiple times, given that all attacks in a flurry occur near simultaneously.



Here is the typical two blow flurry when attacking a creature with an on-hit unique power on the armor.

These two occur within a millisecond
OnPhysicalAttacked Event fires for first attack
OnPhysicalAttacked Event fires for second attack

Delay

These six occur within a millisecond
OnHit power fires for second attack
OnDamaged Event fires for second attack
Damage Dealt for the second attack
OnHit power fires for first attack
OnDamaged Event fires for first attack
Damage Dealt for the first attack

So if you want to ensure unique damage your delay looks like it should be under a millisecond.  This might be feasible, but I don't know how such short delays may work in practice.

EDIT: Didn't realize that within a flurry the damages are consistently put in reverse order of the blows
               
               

               


                     Modifié par WhiZard, 16 février 2012 - 07:42 .