I created a system that is based on the loot creation tables from D&D. he example below is for weapon generation. it uses a base weapon and applied item properties to it on the fly. Also gives a basic descriptive name to the item. Let me post a piece of it here. If you think it worth the effort I can pull it from my server and post to vault...I have never release any of my work before, but there is much I would share now.
A call to any of the methods included in the void main will generate a totally custom item on the fly.
Create the required base weapon items for the system in the toolset. Look at the GetIs* meathods/functions to see what the required resrefs are for the base weapon items and have some fun.
/*::////////////////////////////////////////////////////////////////////////////
//:: Name: KMdS PNP Hard Core Rule Set 1.0
//:: System: KMdS AD&D Treasure System
//:: FileName Gen_My_Weapons
//:: Copyright (c) 2004 Michael Careaga
//::////////////////////////////////////////////////////////////////////////////
This script controls what type of magical/mundane weapons are created on a spawned
monster based on the loot table used in the spawn_cfg_loot.nss script for
any encounter.
You may add any custom weapons here if you so chose. To do this
you must use the ResRef's for all custom items. All you need for any
original NWN weapons is the TAG of the weapons. It is as true to the pen and
paper d&d system as is possible given the scripting and item possibilities
of NWN and is designed for use with the NESS 8.3 spawn system.
Files incuded in this system are the following.....
Gen_My_Mundane Gen_My_Magic
Gen_My_Armor Gen_My_Bags
Gen_My_Belts Gen_My_Boots
Gen_My_Cloaks Gen_My_Neck
Gen_My_Potions Gen_My_Rings
Gen_My_Rods Gen_My_Scrolls
Gen_My_Staffs Gen_My_Weapons
Gen_My_Wands Gen_My_Art
Scrolls_Struct Init_Scroll_Cnt
Init_Wand_Cnt Gen_My_Magic_Inc
Wands_Struct
//::////////////////////////////////////////////////////////////////////////////
//:: Created By: Kilr Mik d Spik
//:: Created On: 12/18/2005
//:://////////////////////////////////////////////////////////////////////////*/
// ----------------------------------------------------------------------------
// LIBRARIES
// ----------------------------------------------------------------------------
#include "x2_inc_itemprop"
// ----------------------------------------------------------------------------
// PROTOTYPES
// ----------------------------------------------------------------------------
// The total number of properties to be placed upon an item with a base minimum
// of one property and a maximum of two properties. Set nChance to the base
// percent roll needed for multiple properties to exist on an item. If no there
// is no possible chance for more than 1 property, set nChance to 101 or more.
int DoesWeaponHaveOneOrTwoProperties(int nChance);
int GetIsSlashingWeapon(object oWeapon);
int GetIsBludgeoningWeapon(object oWeapon);
int GetIsPiercingWeapon(object oWeapon);
int GetIsThrownWeapon(object oWeapon);
int GetIsNonThrownRangedWeapon(object oWeapon);
int GetWeaponDamageType(object oWeapon);
string AmmunitionType();
string CommonWeaponType();
string UncommonWeaponType();
string CommonRangedWeaponType();
string WeaponTypeDeterimination(int iRoll = FALSE);
void CreateBaneWeapon(object oWeapon, int nAttackBonus = 0);
void AddBanePropertyToWeapon(object oWeapon, int nRacialType, int nDamageBonus, int nAttackBonus = 0);
void MinorWeaponItemProperties(object oWeapon);
void MediumWeaponItemProperties(object oWeapon);
void MajorWeaponItemProperties(object oWeapon);
void WeaponLight(object oWeapon);
void GenerateMundaneWeapon(object oSpawned, int nQty = 1, int nWeapon = FALSE);
void GenerateMasterworkCommonWeapon(object oSpawned, int nQty = 1);
void GenerateMasterworkUncommonWeapon(object oSpawned, int nQty = 1);
void GenerateMasterworkRangedWeapon(object oSpawned, int nQty = 1);
void GenerateMinorMagicWeapon(object oSpawned, int nQty = 1, int nWeapon = FALSE);
void GenerateMediumMagicWeapon(object oSpawned, int nQty = 1, int nWeapon = FALSE);
void GenerateMajorMagicWeapon(object oSpawned, int nQty = 1, int nWeapon = FALSE);
// ----------------------------------------------------------------------------
// FUNCTIONS
// ----------------------------------------------------------------------------
int DoesWeaponHaveOneOrTwoProperties(int nChance)
{
int nProperties = 1;
int nRoll = d100();
if (nRoll >= nChance) nProperties = 2;
return nProperties;
}
int GetIsSlashingWeapon(object oWeapon)
{
int bIsSlashingWeapon = TestStringAgainstPattern("**¬"+GetStringLowerCase(GetTag(oWeapon))+"¬**",
"¬dwarvenwaraxe¬bastardsword¬scimitar¬longsword¬kama¬greatsword¬greataxe¬throwingaxe¬twobladedsword¬scythe¬"+
"sickle¬whip¬kukri¬katana¬handaxe¬halberd¬battleaxe¬doubleaxe¬");
return bIsSlashingWeapon;
}
int GetIsBludgeoningWeapon(object oWeapon)
{
int bIsBludgeoningWeapon = TestStringAgainstPattern("**¬"+GetStringLowerCase(GetTag(oWeapon))+"¬**",
"¬club¬heavyflail¬lightflail¬lighthammer¬warhammer¬mace¬morningstar¬diremace¬quarterstaff¬bullet¬");
return bIsBludgeoningWeapon;
}
int GetIsPiercingWeapon(object oWeapon)
{
int bIsPiercingWeapon = TestStringAgainstPattern("**¬"+GetStringLowerCase(GetTag(oWeapon))+"¬**",
"¬bastardsword¬longsword¬greatsword¬scythe¬katana¬halberd¬doubleaxe¬shuriken¬dart¬spear¬"+
"rapier¬dagger¬bolt¬arrow¬");
return bIsPiercingWeapon;
}
int GetIsThrownWeapon(object oWeapon)
{
int bIsThrowingWeapon = TestStringAgainstPattern("**¬"+GetStringLowerCase(GetTag(oWeapon))+"¬**",
"¬shuriken¬dart¬throwingaxe¬");
return bIsThrowingWeapon;
}
int GetIsNonThrownRangedWeapon(object oWeapon)
{
int bIsThrowingWeapon = TestStringAgainstPattern("**¬"+GetStringLowerCase(GetResRef(oWeapon))+"¬**",
"¬compositelbow004¬compositelbow003¬compositelbow002¬compositelbow001¬compositelbow¬longbow¬sling¬compositesbow002¬compositesbow001¬compositesbow¬"+
"shortbow¬lightcrossbow¬heavycrossbow¬");
return bIsThrowingWeapon;
}
int GetWeaponDamageType(object oWeapon)
{
int nDamageType;
if (GetIsSlashingWeapon(oWeapon) == TRUE) nDamageType = IP_CONST_DAMAGETYPE_SLASHING;
else if (GetIsBludgeoningWeapon(oWeapon) == TRUE) nDamageType = IP_CONST_DAMAGETYPE_BLUDGEONING;
else nDamageType = IP_CONST_DAMAGETYPE_PIERCING;
return nDamageType;
}
string CommonWeaponType()
{
string sTemplate;
int nRoll = Random(92)+1;
if (nRoll >=82) sTemplate = "dwarvenwaraxe";
else if (nRoll >=77) sTemplate = "shortsword";
else if (nRoll >=67) sTemplate = "bastardsword";
else if (nRoll >=63) sTemplate = "spear";
else if (nRoll >=58) sTemplate = "scimitar";
else if (nRoll >=54) sTemplate = "rapier";
else if (nRoll >=51) sTemplate = "quarterstaff";
else if (nRoll >=42) sTemplate = "mace";
else if (nRoll >=29) sTemplate = "longsword";
else if (nRoll >=25) sTemplate = "kama";
else if (nRoll >=15) sTemplate = "greatsword";
else if (nRoll >= 5) sTemplate = "greataxe";
else sTemplate = "dagger";
return sTemplate;
}
string UncommonWeaponType()
{
string sTemplate;
int nRoll = Random(52)+1;
if (nRoll >=50) sTemplate = "whip";
else if (nRoll >=47) sTemplate = "warhammer";
else if (nRoll >=44) sTemplate = "twobladedsword";
else if (nRoll >=41) sTemplate = "sickle";
else if (nRoll >=39) sTemplate = "shuriken";
else if (nRoll >=37) sTemplate = "scythe";
else if (nRoll >=35) sTemplate = "morningstar";
else if (nRoll >=32) sTemplate = "kukri";
else if (nRoll >=29) sTemplate = "katana";
else if (nRoll >=27) sTemplate = "handaxe";
else if (nRoll >=25) sTemplate = "lighthammer";
else if (nRoll >=22) sTemplate = "halberd";
else if (nRoll >=18) sTemplate = "lightflail";
else if (nRoll >=13) sTemplate = "heavyflail";
else if (nRoll >=10) sTemplate = "diremace";
else if (nRoll >= sTemplate = "club";
else if (nRoll >= 4) sTemplate = "battleaxe";
else sTemplate = "doubleaxe";
return sTemplate;
}
string CommonRangedWeaponType()
{
string sTemplate;
int nRoll = Random(98)+1;
if (nRoll >=94) sTemplate = "compositelbow004";
else if (nRoll >=89) sTemplate = "compositelbow003";
else if (nRoll >=84) sTemplate = "compositelbow002";
else if (nRoll >=79) sTemplate = "compositelbow001";
else if (nRoll >=74) sTemplate = "compositelbow";
else if (nRoll >=64) sTemplate = "longbow";
else if (nRoll >=60) sTemplate = "sling";
else if (nRoll >=55) sTemplate = "compositesbow002";
else if (nRoll >=50) sTemplate = "compositesbow001";
else if (nRoll >=45) sTemplate = "compositesbow";
else if (nRoll >=40) sTemplate = "shortbow";
else if (nRoll >=36) sTemplate = "dart";
else if (nRoll >=26) sTemplate = "lightcrossbow";
else if (nRoll >=16) sTemplate = "heavycrossbow";
else if (nRoll >=11) sTemplate = "throwingaxe";
else sTemplate = AmmunitionType();
return sTemplate;
}
string AmmunitionType()
{
string sTemplate;
int nRoll = Random(100)+1;
if (nRoll >=81) sTemplate = "bullet";
else if (nRoll >=51) sTemplate = "bolt";
else sTemplate = "arrow";
return sTemplate;
}
string WeaponTypeDeterimination(int iRoll = FALSE)
{
string sTemplate;
if(iRoll == FALSE)
iRoll = d100();
if (iRoll >= 81) sTemplate = CommonRangedWeaponType();
else if (iRoll >= 71) sTemplate = UncommonWeaponType();
else sTemplate = CommonWeaponType();
return sTemplate;
}
void CreateBaneWeapon(object oWeapon, int nAttackBonus = 0)
{
string sName = "";
int nRacialType;
int iRoll = d100();
if (iRoll >= 95) {
if (FindSubString(GetName(oWeapon), "Aberration Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_ABERRATION;
sName = "Aberration Bane ";
}
}
else if (iRoll >= 92) {
if (FindSubString(GetName(oWeapon), "Animal Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_ANIMAL;
sName = "Animal Bane ";
}
}
else if (iRoll >= 87) {
if (FindSubString(GetName(oWeapon), "Beast Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_BEAST;
sName = "Beast Bane ";
}
}
else if (iRoll >= 80) {
if (FindSubString(GetName(oWeapon), "Construct Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_CONSTRUCT;
sName = "Construct Bane ";
}
}
else if (iRoll >= 75) {
if (FindSubString(GetName(oWeapon), "Dragon Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_DRAGON;
sName = "Dragon Bane ";
}
}
else if (iRoll >= 74) {
if (FindSubString(GetName(oWeapon), "Dwarf Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_DWARF;
sName = "Dwarf Bane ";
}
}
else if (iRoll >= 69) {
if (FindSubString(GetName(oWeapon), "Elemental Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_ELEMENTAL;
sName = "Elemental Bane ";
}
}
else if (iRoll >= 68) {
if (FindSubString(GetName(oWeapon), "Elf Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_ELF;
sName = "Elf Bane ";
}
}
else if (iRoll >= 63) {
if (FindSubString(GetName(oWeapon), "Fey Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_FEY;
sName = "Fey Bane ";
}
}
else if (iRoll >= 58) {
if (FindSubString(GetName(oWeapon), "Giant Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_GIANT;
sName = "Giant Bane ";
}
}
else if (iRoll >= 57) {
if (FindSubString(GetName(oWeapon), "Gnome Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_GNOME;
sName = "Gnome Bane ";
}
}
else if (iRoll >= 56) {
if (FindSubString(GetName(oWeapon), "Half-Elf Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_HALFELF;
sName = "Half-Elf Bane ";
}
}
else if (iRoll >= 55) {
if (FindSubString(GetName(oWeapon), "Halfling Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_HALFLING;
sName = "Halfling Bane ";
}
}
else if (iRoll >= 54) {
if (FindSubString(GetName(oWeapon), "Half-Orc Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_HALFORC;
sName = "Half-Orc Bane ";
}
}
else if (iRoll >= 53) {
if (FindSubString(GetName(oWeapon), "Human Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_HUMAN;
sName = "Human Bane ";
}
}
else if (iRoll >= 52) {
if (FindSubString(GetName(oWeapon), "Goblin Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_HUMANOID_GOBLINOID;
sName = "Goblin Bane ";
}
}
else if (iRoll >= 47) {
if (FindSubString(GetName(oWeapon), "Monstrous Humaniod Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_HUMANOID_MONSTROUS;
sName = "Monstrous Humaniod Bane ";
}
}
else if (iRoll >= 46) {
if (FindSubString(GetName(oWeapon), "Orc Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_HUMANOID_ORC;
sName = "Orc Bane ";
}
}
else if (iRoll >= 45) {
if (FindSubString(GetName(oWeapon), "Reptilian Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_HUMANOID_REPTILIAN;
sName = "Reptilian Bane ";
}
}
else if (iRoll >= 40) {
if (FindSubString(GetName(oWeapon), "Magical Beast Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_MAGICAL_BEAST;
sName = "Magical Beast Bane ";
}
}
else if (iRoll >= 18) {
if (FindSubString(GetName(oWeapon), "Outsider Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_OUTSIDER;
sName = "Outsider Bane ";
}
}
else if (iRoll >= 10) {
if (FindSubString(GetName(oWeapon), "Shapchanger Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_SHAPECHANGER;
sName = "Shapchanger Bane ";
}
}
else if (iRoll >= 3) {
if (FindSubString(GetName(oWeapon), "Undead Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_UNDEAD;
sName = "Undead Bane ";
}
}
else {
if (FindSubString(GetName(oWeapon), "Vermin Bane") != -1)
CreateBaneWeapon(oWeapon, nAttackBonus);
else{
nRacialType = IP_CONST_RACIALTYPE_VERMIN;
sName = "Vermin Bane ";
}
}
AddBanePropertyToWeapon(oWeapon, nRacialType, IP_CONST_DAMAGEBONUS_2d6, nAttackBonus);
SetName(oWeapon, sName+GetName(oWeapon));
}
void AddBanePropertyToWeapon(object oWeapon, int nRacialType, int nDamageBonus, int nAttackBonus = 0)
{
itemproperty ipAdd;
if (GetIsThrownWeapon(oWeapon) == TRUE || IPGetIsMeleeWeapon(oWeapon) == TRUE)
{
ipAdd = ItemPropertyEnhancementBonusVsRace(nRacialType,IPGetWeaponEnhancementBonus(oWeapon) + 2);
IPSafeAddItemProperty(oWeapon, ipAdd);
}
if (GetIsThrownWeapon(oWeapon) == TRUE || IPGetIsMeleeWeapon(oWeapon) == TRUE || IPGetIsProjectile(oWeapon) == TRUE)
{
ipAdd = ItemPropertyDamageBonusVsRace(nRacialType,GetWeaponDamageType(oWeapon),nDamageBonus);
IPSafeAddItemProperty(oWeapon, ipAdd);
}
if (nAttackBonus >=1)
{
ipAdd = ItemPropertyAttackBonusVsRace(nRacialType, nAttackBonus + 2);
IPSafeAddItemProperty(oWeapon, ipAdd);
}
}
void MinorWeaponItemProperties(object oWeapon)
{
if (GetIsNonThrownRangedWeapon(oWeapon) == TRUE)
return;
int nChanceOfMultipleItemProperties = 100;
if (IPGetIsProjectile(oWeapon) == TRUE)
nChanceOfMultipleItemProperties = 101;
string sName = "";
itemproperty ipAdd;
int nProperties = DoesWeaponHaveOneOrTwoProperties(nChanceOfMultipleItemProperties);
int iRoll = Random(100)+1;
if (iRoll >= 86)
{
int i;
for (i = 0; i < nProperties; i++)
{
iRoll = Random(55)+1;
if (iRoll >= 46)
{
if (FindSubString(GetName(oWeapon), "Fire") != -1)
i--;
else{
ipAdd = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_FIRE, IP_CONST_DAMAGEBONUS_1d6);
if (i == 0) sName = " of Fire"; if (i == 1) sName = " and Fire";
IPSafeAddItemProperty(oWeapon, ipAdd);
}
}
else if (iRoll >= 36)
{
if (FindSubString(GetName(oWeapon), "Ice") != -1)
i--;
else{
ipAdd = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_COLD, IP_CONST_DAMAGEBONUS_1d6);
if (i == 0) sName = " of Ice"; if (i == 1) sName = " and Ice";
IPSafeAddItemProperty(oWeapon, ipAdd);
}
}
else if (iRoll >= 26)
{
if (FindSubString(GetName(oWeapon), "Electricity") != -1)
i--;
else{
ipAdd = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_ELECTRICAL, IP_CONST_DAMAGEBONUS_1d6);
if (i == 0) sName = " of Electricity"; if (i == 1) sName = " and Electricity";
IPSafeAddItemProperty(oWeapon, ipAdd);
}
}
else if (iRoll >= 11)
{
if (GetIsSlashingWeapon(oWeapon) == TRUE && IPGetIsMeleeWeapon(oWeapon) == TRUE)
{
if (FindSubString(GetName(oWeapon), "Keen") != -1)
i--;
else{
ipAdd = ItemPropertyKeen();
sName = "Keen ";
IPSafeAddItemProperty(oWeapon, ipAdd);
}
}
else i--;
}
else
{
if (IPGetIsMeleeWeapon(oWeapon) == TRUE)
{
if (FindSubString(GetName(oWeapon), "Cleaving") != -1)
i--;
else{
ipAdd = ItemPropertyBonusFeat(IP_CONST_FEAT_CLEAVE);
sName = "Cleaving ";
IPSafeAddItemProperty(oWeapon, ipAdd);
}
}
else i--;
}
if (sName == "Keen " || sName == "Cleaving ")
SetName(oWeapon, sName+GetName(oWeapon));
else
SetName(oWeapon, GetName(oWeapon)+sName);
}
}
}
void MediumWeaponItemProperties(object oWeapon)
{
if (GetIsNonThrownRangedWeapon(oWeapon) == TRUE)
return;
int nChanceOfMultipleItemProperties = 96;
if (IPGetIsProjectile(oWeapon) == TRUE)
nChanceOfMultipleItemProperties = 99;
string sName = "";
itemproperty ipAdd1;
itemproperty ipAdd2;
int nProperties = DoesWeaponHaveOneOrTwoProperties(nChanceOfMultipleItemProperties);
int iRoll = Random(100)+1;
if (iRoll >= 69)
{
int i;
for (i = 0; i < nProperties; i++)
{
iRoll = Random(61)+1;
if (iRoll >= 57)
{
if (FindSubString(GetName(oWeapon), "Fire") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_FIRE, IP_CONST_DAMAGEBONUS_1d6);
if (i == 0) sName = " of Fire"; if (i == 1) sName = " and Fire";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
else if (iRoll >= 52)
{
if (FindSubString(GetName(oWeapon), "Ice") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_COLD, IP_CONST_DAMAGEBONUS_1d6);
if (i == 0) sName = " of Ice"; if (i == 1) sName = " and Ice";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
else if (iRoll >= 47)
{
if (FindSubString(GetName(oWeapon), "Electricity") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_ELECTRICAL, IP_CONST_DAMAGEBONUS_1d6);
if (i == 0) sName = " of Electricity"; if (i == 1) sName = " and Electricity";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
else if (iRoll >= 37)
{
if (GetIsSlashingWeapon(oWeapon) == TRUE)
{
if (FindSubString(GetName(oWeapon), "Keen") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyKeen();
sName = "Keen ";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
else i--;
}
else if (iRoll >= 27)
{
if (IPGetIsMeleeWeapon(oWeapon) == TRUE)
{
if (FindSubString(GetName(oWeapon), "Cleaving") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyBonusFeat(FEAT_GREAT_CLEAVE);
sName = "Cleaving ";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
else i--;
}
else if (iRoll >= 24)
{
CreateBaneWeapon(oWeapon);
}
else if (iRoll >= 21)
{
if (GetIsBludgeoningWeapon(oWeapon) == TRUE && IPGetIsProjectile(oWeapon) == FALSE)
{
if (FindSubString(GetName(oWeapon), "Undead Slaying") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyOnHitProps(IP_CONST_ONHIT_SLAYRACE, 14, IP_CONST_RACIALTYPE_UNDEAD);
if (i == 0) sName = " of Undead Slaying"; if (i == 1) sName = " and Undead Slaying";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
else i--;
}
else if (iRoll >= 16)
{
if (FindSubString(GetName(oWeapon), "Sonic") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_SONIC, IP_CONST_DAMAGEBONUS_1d6);
sName = "Sonic ";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
else if (iRoll >= 13)
{
if ( IPGetIsProjectile(oWeapon) == FALSE)
{
if (FindSubString(GetName(oWeapon), "Wounding") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyOnHitProps(IP_CONST_ONHIT_WOUNDING, IP_CONST_ONHIT_SAVEDC_16);
if (i == 0) sName = " of Wounding"; if (i == 1) sName = " and Wounding";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
}
else if (iRoll >= 10)
{
if (FindSubString(GetName(oWeapon), "Holy") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonusVsAlign(IP_CONST_ALIGNMENTGROUP_EVIL, GetWeaponDamageType(oWeapon), IP_CONST_DAMAGEBONUS_2d6);
ipAdd2 = ItemPropertyLimitUseByAlign(IP_CONST_ALIGNMENTGROUP_GOOD);
sName = "Holy ";
IPSafeAddItemProperty(oWeapon, ipAdd1);
IPSafeAddItemProperty(oWeapon, ipAdd2);
}
}
else if (iRoll >= 7)
{
if (FindSubString(GetName(oWeapon), "UnHoly") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonusVsAlign(IP_CONST_ALIGNMENTGROUP_GOOD, GetWeaponDamageType(oWeapon), IP_CONST_DAMAGEBONUS_2d6);
ipAdd2 = ItemPropertyLimitUseByAlign(IP_CONST_ALIGNMENTGROUP_EVIL);
sName = "UnHoly ";
IPSafeAddItemProperty(oWeapon, ipAdd1);
IPSafeAddItemProperty(oWeapon, ipAdd2);
}
}
else if (iRoll >= 4)
{
if (FindSubString(GetName(oWeapon), "Lawful") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonusVsAlign(IP_CONST_ALIGNMENTGROUP_CHAOTIC, GetWeaponDamageType(oWeapon), IP_CONST_DAMAGEBONUS_2d6);
ipAdd2 = ItemPropertyLimitUseByAlign(IP_CONST_ALIGNMENTGROUP_LAWFUL);
sName = "Lawful ";
IPSafeAddItemProperty(oWeapon, ipAdd1);
IPSafeAddItemProperty(oWeapon, ipAdd2);
}
}
else
{
if (FindSubString(GetName(oWeapon), "Chaotic") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonusVsAlign(IP_CONST_ALIGNMENTGROUP_LAWFUL, GetWeaponDamageType(oWeapon), IP_CONST_DAMAGEBONUS_2d6);
ipAdd2 = ItemPropertyLimitUseByAlign(IP_CONST_ALIGNMENTGROUP_CHAOTIC);
sName = "Chaotic ";
IPSafeAddItemProperty(oWeapon, ipAdd1);
IPSafeAddItemProperty(oWeapon, ipAdd2);
}
}
if (sName == "Keen " || sName == "Cleaving " || sName == "Sonic " || sName == "Holy " ||
sName == "UnHoly " || sName == "Lawful " ||sName == "Chaotic ")
SetName(oWeapon, sName+GetName(oWeapon));
else
SetName(oWeapon, GetName(oWeapon)+sName);
}
}
}
void MajorWeaponItemProperties(object oWeapon)
{
if (GetIsNonThrownRangedWeapon(oWeapon) == TRUE)
return;
int nChanceOfMultipleItemProperties = 81;
if (IPGetIsProjectile(oWeapon) == TRUE)
nChanceOfMultipleItemProperties = 98;
string sName = "";
itemproperty ipAdd1;
itemproperty ipAdd2;
int nProperties = DoesWeaponHaveOneOrTwoProperties(nChanceOfMultipleItemProperties);
int iRoll = Random(100)+1;
if (iRoll >= 64)
{
int i;
for (i = 0; i < nProperties; i++)
{
iRoll = Random(50)+1;
if (iRoll >= 48)
{
if (FindSubString(GetName(oWeapon), "Fire") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_FIRE, IP_CONST_DAMAGEBONUS_1d6);
if (i == 0) sName = " of Fire"; if (i == 1) sName = " and Fire";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
else if (iRoll >= 45)
{
if (FindSubString(GetName(oWeapon), "Ice") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_COLD, IP_CONST_DAMAGEBONUS_1d6);
if (i == 0) sName = " of Ice"; if (i == 1) sName = " and Ice";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
else if (iRoll >= 42)
{
if (FindSubString(GetName(oWeapon), "Electricity") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_ELECTRICAL, IP_CONST_DAMAGEBONUS_1d6);
if (i == 0) sName = " of Electricity"; if (i == 1) sName = " and Electricity";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
else if (iRoll >= 37)
{
if (IPGetIsMeleeWeapon(oWeapon) == TRUE)
{
if (FindSubString(GetName(oWeapon), "Great Cleaving") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyBonusFeat(FEAT_GREAT_CLEAVE);
sName = "Great Cleaving ";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
else i--;
}
else if (iRoll >= 32)
{
CreateBaneWeapon(oWeapon);
}
else if (iRoll >= 29)
{
if (GetIsBludgeoningWeapon(oWeapon) == TRUE && IPGetIsProjectile(oWeapon) == FALSE)
{
if (FindSubString(GetName(oWeapon), "Undead Slaying") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyOnHitProps(IP_CONST_ONHIT_SLAYRACE, 14, IP_CONST_RACIALTYPE_UNDEAD);
if (i == 0) sName = " of Undead Slaying"; if (i == 1) sName = " and Undead Slaying";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
else i--;
}
else if (iRoll >= 26)
{
if (FindSubString(GetName(oWeapon), "Sonic") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_SONIC, IP_CONST_DAMAGEBONUS_1d6);
sName = "Sonic ";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
else if (iRoll >= 24)
{
if ( IPGetIsProjectile(oWeapon) == FALSE)
{
if (FindSubString(GetName(oWeapon), "Wounding") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyOnHitProps(IP_CONST_ONHIT_WOUNDING, IP_CONST_ONHIT_SAVEDC_16);
if (i == 0) sName = " of Wounding"; if (i == 1) sName = " and Wounding";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
}
else if (iRoll >= 19)
{
if (FindSubString(GetName(oWeapon), "Holy") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonusVsAlign(IP_CONST_ALIGNMENTGROUP_EVIL, GetWeaponDamageType(oWeapon), IP_CONST_DAMAGEBONUS_2d6);
ipAdd2 = ItemPropertyLimitUseByAlign(IP_CONST_ALIGNMENTGROUP_GOOD);
sName = "Holy ";
IPSafeAddItemProperty(oWeapon, ipAdd1);
IPSafeAddItemProperty(oWeapon, ipAdd2);
}
}
else if (iRoll >= 14)
{
if (FindSubString(GetName(oWeapon), "UnHoly") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonusVsAlign(IP_CONST_ALIGNMENTGROUP_GOOD, GetWeaponDamageType(oWeapon), IP_CONST_DAMAGEBONUS_2d6);
ipAdd2 = ItemPropertyLimitUseByAlign(IP_CONST_ALIGNMENTGROUP_EVIL);
sName = "UnHoly ";
IPSafeAddItemProperty(oWeapon, ipAdd1);
IPSafeAddItemProperty(oWeapon, ipAdd2);
}
}
else if (iRoll >= 9)
{
if (FindSubString(GetName(oWeapon), "Lawfull") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonusVsAlign(IP_CONST_ALIGNMENTGROUP_CHAOTIC, GetWeaponDamageType(oWeapon), IP_CONST_DAMAGEBONUS_2d6);
ipAdd2 = ItemPropertyLimitUseByAlign(IP_CONST_ALIGNMENTGROUP_LAWFUL);
sName = "Lawfull ";
IPSafeAddItemProperty(oWeapon, ipAdd1);
IPSafeAddItemProperty(oWeapon, ipAdd2);
}
}
else if (iRoll >= 4)
{
if (FindSubString(GetName(oWeapon), "Chaotic") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyDamageBonusVsAlign(IP_CONST_ALIGNMENTGROUP_LAWFUL, GetWeaponDamageType(oWeapon), IP_CONST_DAMAGEBONUS_2d6);
ipAdd2 = ItemPropertyLimitUseByAlign(IP_CONST_ALIGNMENTGROUP_CHAOTIC);
sName = "Chaotic ";
IPSafeAddItemProperty(oWeapon, ipAdd1);
IPSafeAddItemProperty(oWeapon, ipAdd2);
}
}
else
{
if (GetIsSlashingWeapon(oWeapon) == TRUE)
{
if (FindSubString(GetName(oWeapon), "Vorpal") != -1){
i--;
}
else{
ipAdd1 = ItemPropertyOnHitProps(IP_CONST_ONHIT_VORPAL,IP_CONST_ONHIT_SAVEDC_26);
sName = "Vorpal ";
IPSafeAddItemProperty(oWeapon, ipAdd1);
}
}
else i--;
}
if (sName == "Keen " || sName == "Great Cleaving " || sName == "Sonic " || sName == "Holy " ||
sName == "UnHoly " || sName == "Lawful " ||sName == "Chaotic " ||sName == "Vorpal ")
SetName(oWeapon, sName+GetName(oWeapon));
else
SetName(oWeapon, GetName(oWeapon)+sName);
}
}
}
void WeaponLight(object oWeapon)
{
if (IPGetIsProjectile(oWeapon) == TRUE)
return;
int nRoll = d100();
int nBrightness = IP_CONST_LIGHTBRIGHTNESS_BRIGHT;
int nColor;
if (nRoll >= 71)
{
//Get the first itemproperty on the helmet
itemproperty ipLoop=GetFirstItemProperty(oWeapon);
//Loop for as long as the ipLoop variable is valid unill the first unique property is found for light.
while (GetIsItemPropertyValid(ipLoop))
{
if (IPGetIsProjectile(oWeapon) == FALSE)
{
if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_DAMAGE_BONUS && GetItemPropertySubType(ipLoop) == IP_CONST_DAMAGETYPE_ACID)
{nColor = IP_CONST_LIGHTCOLOR_GREEN;break;}
else if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_DAMAGE_BONUS && GetItemPropertySubType(ipLoop) == IP_CONST_DAMAGETYPE_COLD)
{nColor = IP_CONST_LIGHTCOLOR_BLUE;break;}
else if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_DAMAGE_BONUS && GetItemPropertySubType(ipLoop) == IP_CONST_DAMAGETYPE_DIVINE)
{nColor = IP_CONST_LIGHTCOLOR_WHITE;break;}
else if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_DAMAGE_BONUS && GetItemPropertySubType(ipLoop) == IP_CONST_DAMAGETYPE_ELECTRICAL)
{nColor = IP_CONST_LIGHTCOLOR_PURPLE;break;}
else if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_DAMAGE_BONUS && GetItemPropertySubType(ipLoop) == IP_CONST_DAMAGETYPE_FIRE)
{nColor = IP_CONST_LIGHTCOLOR_ORANGE;break;}
else if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_DAMAGE_BONUS && GetItemPropertySubType(ipLoop) == IP_CONST_DAMAGETYPE_MAGICAL)
{nColor = IP_CONST_LIGHTCOLOR_WHITE;break;}
else if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_DAMAGE_BONUS && GetItemPropertySubType(ipLoop) == IP_CONST_DAMAGETYPE_NEGATIVE)
{nColor = IP_CONST_LIGHTCOLOR_RED;break;}
else if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_DAMAGE_BONUS && GetItemPropertySubType(ipLoop) == IP_CONST_DAMAGETYPE_POSITIVE)
{nColor = IP_CONST_LIGHTCOLOR_BLUE;break;}
else if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_DAMAGE_BONUS && GetItemPropertySubType(ipLoop) == IP_CONST_DAMAGETYPE_SONIC)
{nColor = IP_CONST_LIGHTCOLOR_WHITE;break;}
else if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_DAMAGE_BONUS_VS_ALIGNMENT_GROUP && GetItemPropertySubType(ipLoop) == IP_CONST_ALIGNMENTGROUP_CHAOTIC)
{nColor = IP_CONST_LIGHTCOLOR_PURPLE;break;}
else if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_DAMAGE_BONUS_VS_ALIGNMENT_GROUP && GetItemPropertySubType(ipLoop) == IP_CONST_ALIGNMENTGROUP_EVIL)
{nColor = IP_CONST_LIGHTCOLOR_WHITE;break;}
else if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_DAMAGE_BONUS_VS_ALIGNMENT_GROUP && GetItemPropertySubType(ipLoop) == IP_CONST_ALIGNMENTGROUP_GOOD)
{nColor = IP_CONST_LIGHTCOLOR_RED;break;}
else if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_DAMAGE_BONUS_VS_ALIGNMENT_GROUP && GetItemPropertySubType(ipLoop) == IP_CONST_ALIGNMENTGROUP_LAWFUL)
{nColor = IP_CONST_LIGHTCOLOR_ORANGE;break;}
else if (IPGetItemHasItemOnHitPropertySubType(oWeapon, 24)) //Vorpal
{nColor = IP_CONST_LIGHTCOLOR_ORANGE;break;}
else if (IPGetItemHasItemOnHitPropertySubType(oWeapon, 25)) //Wounding
{nColor = IP_CONST_LIGHTCOLOR_RED;break;}
else
nColor = IP_CONST_LIGHTCOLOR_YELLOW;
}
//Next itemproperty on the list...
ipLoop=GetNextItemProperty(oWeapon);
}
itemproperty ipAdd = ItemPropertyLight(nBrightness, nColor);
IPSafeAddItemProperty(oWeapon, ipAdd);
}
}
void GenerateMundaneWeapon(object oSpawned, int nQty = 1, int nWeapon = FALSE)
{
int i;
for(i=0; i<nQty; i++){
int nQty = 1;
string sTemplate = WeaponTypeDeterimination();
if (sTemplate == "bullet" || sTemplate == "arrow" || sTemplate == "bolt") nQty = 99;
if (sTemplate == "shuriken" || sTemplate == "throwingaxe" || sTemplate == "dart") nQty = 50;
object oWeapon = CreateItemOnObject(sTemplate, oSpawned, nQty);
}
}
void GenerateMasterworkCommonWeapon(object oSpawned, int nQty = 1)
{
int i;
for(i=0; i<nQty; i++){
string sTemplate = CommonWeaponType();
object oWeapon = CreateItemOnObject(sTemplate, oSpawned, 1);
if (GetIsObjectValid(oWeapon) == FALSE) return;
itemproperty ipAdd = ItemPropertyAttackBonus(1);
IPSafeAddItemProperty(oWeapon, ipAdd);
SetName(oWeapon, "Masterwork "+GetName(oWeapon));
}
}
void GenerateMasterworkUncommonWeapon(object oSpawned, int nQty = 1)
{
int i;
for(i=0; i<nQty; i++){
int nQty = 1;
string sTemplate = UncommonWeaponType();
if (sTemplate == "bullet" || sTemplate == "arrow" || sTemplate == "bolt") nQty = 99;
if (sTemplate == "shuriken" || sTemplate == "throwingaxe" || sTemplate == "dart") nQty = 50;
object oWeapon = CreateItemOnObject(sTemplate, oSpawned, nQty);
if (GetIsObjectValid(oWeapon) == FALSE) return;
itemproperty ipAdd = ItemPropertyAttackBonus(1);
IPSafeAddItemProperty(oWeapon, ipAdd);
SetName(oWeapon, "Masterwork "+GetName(oWeapon));
}
}
void GenerateMasterworkRangedWeapon(object oSpawned, int nQty = 1)
{
int i;
for(i=0; i<nQty; i++){
int nQty = 1;
string sTemplate = CommonRangedWeaponType();
if (sTemplate == "bullet" || sTemplate == "arrow" || sTemplate == "bolt") nQty = 99;
if (sTemplate == "shuriken" || sTemplate == "throwingaxe" || sTemplate == "dart") nQty = 50;
object oWeapon = CreateItemOnObject(sTemplate, oSpawned, nQty);
if (GetIsObjectValid(oWeapon) == FALSE) return;
itemproperty ipAdd = ItemPropertyAttackBonus(1);
if (IPGetIsProjectile(oWeapon) == TRUE)
ipAdd = ItemPropertyDamageBonus(GetWeaponDamageType(oWeapon), IP_CONST_DAMAGEBONUS_1);
IPSafeAddItemProperty(oWeapon, ipAdd);
SetName(oWeapon, "Masterwork "+GetName(oWeapon));
}
}
void GenerateMinorMagicWeapon(object oSpawned, int nQty = 1, int nWeapon = FALSE)
{
int i;
for(i=0; i<nQty; i++){
string sName = "";
int nQty = 1;
string sTemplate = WeaponTypeDeterimination();
if (sTemplate == "bullet" || sTemplate == "arrow" || sTemplate == "bolt") nQty = 99;
if (sTemplate == "shuriken" || sTemplate == "throwingaxe" || sTemplate == "dart") nQty = 50;
object oWeapon = CreateItemOnObject(sTemplate, oSpawned, nQty);
int nEnchantmentBonus;
int iRoll;
itemproperty ipAdd;
int nDamageType;
if (GetIsObjectValid(oWeapon) == FALSE) return;
if (IPGetIsProjectile(oWeapon) == FALSE && GetIsNonThrownRangedWeapon(oWeapon) == FALSE)
{
iRoll = Random(85)+1;
nEnchantmentBonus = 1;
if (iRoll >= 71) nEnchantmentBonus = 2;
ipAdd = ItemPropertyEnhancementBonus(nEnchantmentBonus);
SetName(oWeapon, GetName(oWeapon)+" +"+IntToString(nEnchantmentBonus));
IPSafeAddItemProperty(oWeapon, ipAdd);
}
else if (IPGetIsProjectile(oWeapon) == TRUE)// (bolt, arrow, etc)
{
iRoll = Random(85)+1;
nDamageType = IP_CONST_DAMAGETYPE_PIERCING;
sName = " of Piercing";
if(GetStringLowerCase(GetTag(oWeapon))=="bullet"){
nDamageType = IP_CONST_DAMAGETYPE_BLUDGEONING;
sName = " of Bludgeoning";
}
nEnchantmentBonus = IP_CONST_DAMAGEBONUS_1;
if (iRoll >= 71)
nEnchantmentBonus = IP_CONST_DAMAGEBONUS_2;
sName += (" +"+IntToString(nEnchantmentBonus));
SetName(oWeapon, GetName(oWeapon)+sName);
ipAdd = ItemPropertyDamageBonus(nDamageType, nEnchantmentBonus);
IPSafeAddItemProperty(oWeapon, ipAdd);
}
else if (GetIsNonThrownRangedWeapon(oWeapon) == TRUE)
{
iRoll = Random(85)+1;
nEnchantmentBonus = 1;
if (iRoll >= 71) nEnchantmentBonus = 2;
SetName(oWeapon, GetName(oWeapon)+" +"+IntToString(nEnchantmentBonus));
ipAdd = ItemPropertyAttackBonus(nEnchantmentBonus);
IPSafeAddItemProperty(oWeapon, ipAdd);
}
if (GetIsNonThrownRangedWeapon(oWeapon) == FALSE)
MinorWeaponItemProperties(oWeapon);
WeaponLight(oWeapon);
}
}
void GenerateMediumMagicWeapon(object oSpawned, int nQty = 1, int nWeapon = FALSE)
{
int i;
for(i=0; i<nQty; i++){
string sName = "";
int nQty = 1;
string sTemplate = WeaponTypeDeterimination();
if (sTemplate == "bullet" || sTemplate == "arrow" || sTemplate == "bolt") nQty = 99;
if (sTemplate == "shuriken" || sTemplate == "throwingaxe" || sTemplate == "dart") nQty = 50;
object oWeapon = CreateItemOnObject(sTemplate, oSpawned, nQty);
int nEnchantmentBonus;
int iRoll;
itemproperty ipAdd;
int nDamageType;
if (GetIsObjectValid(oWeapon) == FALSE) return;
if (IPGetIsProjectile(oWeapon) == FALSE && GetIsNonThrownRangedWeapon(oWeapon) == FALSE)
{
iRoll = Random(62)+1;
nEnchantmentBonus = 1;
if (iRoll >= 59) nEnchantmentBonus = 4;
else if (iRoll >= 21) nEnchantmentBonus = 3;
else if (iRoll >= 11) nEnchantmentBonus = 2;
ipAdd = ItemPropertyEnhancementBonus(nEnchantmentBonus);
SetName(oWeapon, GetName(oWeapon)+" +"+IntToString(nEnchantmentBonus));
IPSafeAddItemProperty(oWeapon, ipAdd);
}
else if (IPGetIsProjectile(oWeapon) == TRUE)
{
iRoll = Random(62)+1;
nDamageType = IP_CONST_DAMAGETYPE_PIERCING;
sName = " of Piercing";
if(GetStringLowerCase(GetTag(oWeapon))=="bullet"){
nDamageType = IP_CONST_DAMAGETYPE_BLUDGEONING;
sName = " of Bludgeoning";
}
nEnchantmentBonus = IP_CONST_DAMAGEBONUS_1;
if (iRoll >= 59) nEnchantmentBonus = IP_CONST_DAMAGEBONUS_4;
else if (iRoll >= 21) nEnchantmentBonus = IP_CONST_DAMAGEBONUS_3;
else if (iRoll >= 11) nEnchantmentBonus = IP_CONST_DAMAGEBONUS_2;
sName += (" +"+IntToString(nEnchantmentBonus));
SetName(oWeapon, GetName(oWeapon)+sName);
ipAdd = ItemPropertyDamageBonus(nDamageType, nEnchantmentBonus);
IPSafeAddItemProperty(oWeapon, ipAdd);
}
else if (GetIsNonThrownRangedWeapon(oWeapon) == TRUE)
{
iRoll = Random(62)+1;
nEnchantmentBonus = 1;
if (iRoll >= 59) nEnchantmentBonus = 4;
else if (iRoll >= 21) nEnchantmentBonus = 3;
else if (iRoll >= 11) nEnchantmentBonus = 2;
SetName(oWeapon, GetName(oWeapon)+" +"+IntToString(nEnchantmentBonus));
ipAdd = ItemPropertyAttackBonus(nEnchantmentBonus);
IPSafeAddItemProperty(oWeapon, ipAdd);
iRoll = d100();
if (iRoll >= 69) CreateBaneWeapon(oWeapon, nEnchantmentBonus);
}
if (GetIsNonThrownRangedWeapon(oWeapon) == FALSE)
MediumWeaponItemProperties(oWeapon);
WeaponLight(oWeapon);
}
}
void GenerateMajorMagicWeapon(object oSpawned, int nQty = 1, int nWeapon = FALSE)
{
int i;
for(i=0; i<nQty; i++){
string sName = "";
int nQty = 1;
string sTemplate = WeaponTypeDeterimination();
if (sTemplate == "bullet" || sTemplate == "arrow" || sTemplate == "bolt") nQty = 99;
if (sTemplate == "shuriken" || sTemplate == "throwingaxe" || sTemplate == "dart") nQty = 50;
object oWeapon = CreateItemOnObject(sTemplate, oSpawned, nQty);
int nEnchantmentBonus;
int iRoll;
itemproperty ipAdd;
int nDamageType;
if (GetIsObjectValid(oWeapon) == FALSE) return;
if (IPGetIsProjectile(oWeapon) == FALSE && GetIsNonThrownRangedWeapon(oWeapon) == FALSE)
{
iRoll = Random(49)+1;
nEnchantmentBonus = 3;
if (iRoll >= 39) nEnchantmentBonus = 5;
else if (iRoll >= 21) nEnchantmentBonus = 4;
ipAdd = ItemPropertyEnhancementBonus(nEnchantmentBonus);
SetName(oWeapon, GetName(oWeapon)+" +"+IntToString(nEnchantmentBonus));
IPSafeAddItemProperty(oWeapon, ipAdd);
}
else if (IPGetIsProjectile(oWeapon) == TRUE)
{
iRoll = Random(49)+1;
nDamageType = IP_CONST_DAMAGETYPE_PIERCING;
sName = " of Piercing";
if(GetStringLowerCase(GetTag(oWeapon))=="bullet"){
nDamageType = IP_CONST_DAMAGETYPE_BLUDGEONING;
sName = " of Bludgeoning";
}
nEnchantmentBonus = IP_CONST_DAMAGEBONUS_3;
if (iRoll >= 39) nEnchantmentBonus = IP_CONST_DAMAGEBONUS_5;
else if (iRoll >= 21) nEnchantmentBonus = IP_CONST_DAMAGEBONUS_4;
sName += (" +"+IntToString(nEnchantmentBonus));
SetName(oWeapon, GetName(oWeapon)+sName);
ipAdd = ItemPropertyDamageBonus(nDamageType, nEnchantmentBonus);
IPSafeAddItemProperty(oWeapon, ipAdd);
}
else if (GetIsNonThrownRangedWeapon(oWeapon) == TRUE)
{
iRoll = Random(62)+1;
nEnchantmentBonus = 3;
if (iRoll >= 39) nEnchantmentBonus = 5;
else if (iRoll >= 21) nEnchantmentBonus = 4;
SetName(oWeapon, GetName(oWeapon)+" +"+IntToString(nEnchantmentBonus));
ipAdd = ItemPropertyAttackBonus(nEnchantmentBonus);
IPSafeAddItemProperty(oWeapon, ipAdd);
iRoll = d100();
if (iRoll >= 64) CreateBaneWeapon(oWeapon, nEnchantmentBonus);
}
if (GetIsNonThrownRangedWeapon(oWeapon) == FALSE)
MajorWeaponItemProperties(oWeapon);
WeaponLight(oWeapon);
}
}
/* For compiling
void main()
{
GenerateMajorMagicWeapon(OBJECT_SELF);
GenerateMediumMagicWeapon(OBJECT_SELF);
GenerateMinorMagicWeapon(OBJECT_SELF);
GenerateMasterworkRangedWeapon(OBJECT_SELF);
GenerateMasterworkUncommonWeapon(OBJECT_SELF);
GenerateMasterworkCommonWeapon(OBJECT_SELF);
GenerateMundaneWeapon(OBJECT_SELF);
}
// Naming conventions done for NWN v1.67