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 eventReplace 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 NWNXNeither 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 tricksYou 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 hookingA 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 .