When you select an item property that defines the weapon or armor material, for example Mithril, is the effect hard-coded?
In mithril’s case it reduces the weight - where would I see that script?
If you were to add something to iprp_materials, how would it do anything other than show as text in the item description?
Most of the properties are declared in 2DA files and the names in the dialog.tlk file.
So to add a new type of items you need to edit the related 2da files and complete the dialog.tlk file for the names.
i suspect mithral weight reduction is hardcoded. BaseItems.2da has a col “TenthLBS” (weight * 10) … but since i don’t see baseitem entries specific to mithral it strikes me as hardcoded.
I haven’t poked around with materials very much though,
not sure, materials seems to be mostly about getting through damage reductions …
DamageReductions are properties of items and (ironically) can’t be scripted on items (they can be on creatures) despite the functions in NwScript …
at present I’m not confident that new materials could even be added to iprp_materials … DR was drastically modified in nwn2/3.5e … and i don’t think that the nwn2 programmers really got it thoroughly sorted. So my opinion is that there’s a bit of a wall here
but if you want to tinker with it to see what works that’d be great,
[edit]
if you look at for example, Adamantine Battleaxe ( mst_axbt_ada_3 ) notice that
Damage Bonus: Magical [2]
is added as an itemproperty. That is, the bonus is not integral to the material (it’s neither hardcoded nor scripted for adamantine weapons). hence i believe that the material-type is likely only for getting through DR …
in short, I believe that any special characteristics you’d want for a material need to be set as a property on the item or scripted in one way or another.
does a creature’s On Damaged allow bypassing the damage? I have not tried it.
So if get the weapon of the GetLastDamager and check a property, or even easier a local int, to see if its my special “MegaMetal” and creature is immune to this MegaMetal, I can just exit OnDamaged to avoid or set damage to zero, or something?
Just spitballing here
unfortunately i think OnDamaged fires after damage was applied. That is, a creature could be healed back up to whatever health it had before the hit, but i think this requires some fancy footwork … eg. perhaps using the OnPhysicallyAttacked script to get/set what the HP was at, then healing the creature in its OnDamaged script
but there’s issues, like what if the creature got killed from the damage …
this has come up before and it’s a tough one
yes, I can see catching the damage from OnDamaged as being a messy solution
I will keep digging
Ensure a creature is set immortal prior being hit, and then determine results and apply. If result is death, then remove immortal and kill.
When Mithril is used, it is set as an “Armor Type” in the armour behaviour property. This list of armour properties is found in the armorulestats.2da. This 2da is where Mithril’s weight is set, as is other armour types. This is hard-coded. i.e. You cannot add a Mithril property via script. Although, you may be able to duplicate it via some scripting that creates a mithril copy and then copies exisiting properties to the new armour.
I have a similar scenario in my next module … I used a script to make my own creature immune to weapons using EffectDamageImmunityIncrease function for all types (EG: DAMAGE_TYPE_BLUDGEONING) and then removing the “protection” if not immune. Also, assuming you check if your MegaMetal was the weapon material being used in the first place, of course.
I did quite a bit of rework with Materials for the campaign, and have implemented a concept similar to your own here in my next module.
But, using “immortal” may be a quicker and easier way to do what you need. i.e. Only apply any “real” damage after determining how the damage was delivered. If the damage was via the MegaMetal weapon (and the creature is immune) just “restore” the lost damage via heal (creature cannot actually die). If not, then allow the damage to “apply” (keep track of real damage in a variable), and if below current HPS, removal immortal property of creature and kill.
This is why I would use the “immortal” property in such situations, and remove when no longer required.