Initial upload
Initial upload. PRC8 has been added. Module compiles, PRC's default AI & treasure scripts have been integrated. Started work on top hak for SLA / Ability / Scripting modifications.
This commit is contained in:
488
_module/nss/jw_inc_craft.nss
Normal file
488
_module/nss/jw_inc_craft.nss
Normal file
@@ -0,0 +1,488 @@
|
||||
//:: jw_inc_craft.nss
|
||||
|
||||
|
||||
const int X2_CI_MODMODE_HELMET = 3;
|
||||
const int X2_CI_MODMODE_SHIELD = 4;
|
||||
|
||||
// cost to modify oOlditem to look like oNewItem
|
||||
int JWGetWeaponModificationDC (object oOldItem, object oNewItem);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Return the cost
|
||||
// -----------------------------------------------------------------------------
|
||||
int JWGetHelmetModificationCost(object oItem)
|
||||
{
|
||||
int nTotal = 100;
|
||||
|
||||
int nCurrApp = GetItemAppearance(oItem, ITEM_APPR_TYPE_ARMOR_MODEL, 0);
|
||||
|
||||
// Expensive ones
|
||||
if (nCurrApp==8||nCurrApp==13||nCurrApp==16||nCurrApp==21||nCurrApp==22||nCurrApp==23||nCurrApp==25||nCurrApp==27||nCurrApp==28||nCurrApp==29||nCurrApp==31)
|
||||
{
|
||||
nTotal=500;
|
||||
}
|
||||
|
||||
return nTotal;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Return the dc
|
||||
// -----------------------------------------------------------------------------
|
||||
int JWGetHelmetModificationDC(object oItem)
|
||||
{
|
||||
int nTotal = 10;
|
||||
|
||||
int nCurrApp = GetItemAppearance(oItem, ITEM_APPR_TYPE_ARMOR_MODEL, 0);
|
||||
|
||||
// Expensive ones
|
||||
if (nCurrApp==8||nCurrApp==13||nCurrApp==16||nCurrApp==21||nCurrApp==22||nCurrApp==23||nCurrApp==25||nCurrApp==27||nCurrApp==28||nCurrApp==29||nCurrApp==31)
|
||||
{
|
||||
nTotal=25;
|
||||
}
|
||||
|
||||
return nTotal;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Return the cost
|
||||
// -----------------------------------------------------------------------------
|
||||
int JWGetShieldModificationCost(object oItem)
|
||||
{
|
||||
int nTotal = 50;
|
||||
|
||||
int nCurrApp = GetItemAppearance(oItem, ITEM_APPR_TYPE_SIMPLE_MODEL, 0);
|
||||
|
||||
// Expensive ones
|
||||
if (nCurrApp==12||nCurrApp==13||nCurrApp==22||nCurrApp==23||nCurrApp==32||nCurrApp==33||nCurrApp==42||nCurrApp==43)
|
||||
{
|
||||
nTotal=nTotal*2;
|
||||
}
|
||||
|
||||
if (GetBaseItemType(oItem)==BASE_ITEM_LARGESHIELD)
|
||||
{
|
||||
nTotal=nTotal*4;
|
||||
}
|
||||
if (GetBaseItemType(oItem)==BASE_ITEM_TOWERSHIELD)
|
||||
{
|
||||
nTotal=nTotal*8;
|
||||
}
|
||||
|
||||
return nTotal;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Return the dc
|
||||
// -----------------------------------------------------------------------------
|
||||
int JWGetShieldModificationDC(object oItem)
|
||||
{
|
||||
int nTotal = 5;
|
||||
|
||||
int nCurrApp = GetItemAppearance(oItem, ITEM_APPR_TYPE_SIMPLE_MODEL, 0);
|
||||
|
||||
// Expensive ones
|
||||
if (nCurrApp==12||nCurrApp==13||nCurrApp==22||nCurrApp==23||nCurrApp==32||nCurrApp==33||nCurrApp==42||nCurrApp==43)
|
||||
{
|
||||
nTotal=nTotal+5;
|
||||
}
|
||||
|
||||
if (GetBaseItemType(oItem)==BASE_ITEM_LARGESHIELD)
|
||||
{
|
||||
nTotal=nTotal+10;
|
||||
}
|
||||
if (GetBaseItemType(oItem)==BASE_ITEM_TOWERSHIELD)
|
||||
{
|
||||
nTotal=nTotal+15;
|
||||
}
|
||||
|
||||
return nTotal;
|
||||
}
|
||||
|
||||
// cost to modify oOlditem to look like oNewItem
|
||||
int JWGetWeaponModificationDC (object oOldItem, object oNewItem)
|
||||
{
|
||||
int nTotal = 13;
|
||||
int nPart;
|
||||
for (nPart = 0; nPart<=2; nPart++)
|
||||
{
|
||||
if (GetItemAppearance(oOldItem,ITEM_APPR_TYPE_WEAPON_MODEL, nPart) !=GetItemAppearance(oNewItem,ITEM_APPR_TYPE_WEAPON_MODEL, nPart))
|
||||
{
|
||||
nTotal=nTotal+1;
|
||||
}
|
||||
// Palmer now we check for colours
|
||||
if (GetItemAppearance(oOldItem,ITEM_APPR_TYPE_WEAPON_COLOR, nPart) !=GetItemAppearance(oNewItem,ITEM_APPR_TYPE_WEAPON_COLOR, nPart))
|
||||
{
|
||||
nTotal=nTotal+2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nTotal;
|
||||
}
|
||||
|
||||
// Returns a coloured weapon
|
||||
object JWGetColouredWeapon (object oItem, int nPart, int nMode, int bDestroyOldOnSuccess)
|
||||
{
|
||||
// Handle Weapon change
|
||||
int nCurrApp = GetItemAppearance(oItem, ITEM_APPR_TYPE_WEAPON_COLOR, nPart);
|
||||
int nMin = 1;
|
||||
int nMax = 4;
|
||||
|
||||
if (nMode == X2_IP_ARMORTYPE_NEXT) {
|
||||
if (++nCurrApp>nMax) nCurrApp = nMin;
|
||||
} else {
|
||||
if (--nCurrApp<nMin) nCurrApp = nMax;
|
||||
}
|
||||
//SpeakString("Debug New: "+IntToString(nCurrApp));
|
||||
|
||||
object oNew = CopyItemAndModify(oItem, ITEM_APPR_TYPE_WEAPON_COLOR, nPart, nCurrApp, TRUE);
|
||||
|
||||
if (oNew != OBJECT_INVALID)
|
||||
{
|
||||
if( bDestroyOldOnSuccess )
|
||||
{
|
||||
DestroyObject(oItem);
|
||||
}
|
||||
SetLocalInt(oNew,"jw_craft_copy",TRUE);
|
||||
return oNew;
|
||||
}
|
||||
// Safety fallback, return old helmet on failures
|
||||
|
||||
return oItem;
|
||||
}
|
||||
|
||||
// Returns a coloured shield
|
||||
object JWGetColouredShield (object oItem, int nMode, int bDestroyOldOnSuccess)
|
||||
{
|
||||
int nCurrApp = GetItemAppearance(oItem, ITEM_APPR_TYPE_SIMPLE_MODEL, 0);
|
||||
int nMod = (nCurrApp/10)*10;
|
||||
nCurrApp-= nMod;
|
||||
int nMin = 1;
|
||||
int nMax = 3;
|
||||
|
||||
if (nMode == X2_IP_ARMORTYPE_NEXT) {
|
||||
if (++nCurrApp>nMax) nCurrApp = nMin;
|
||||
} else {
|
||||
if (--nCurrApp<nMin) nCurrApp = nMax;
|
||||
}
|
||||
nCurrApp += nMod;
|
||||
|
||||
|
||||
// round the clock
|
||||
if (nCurrApp==51)
|
||||
{
|
||||
nCurrApp=11;
|
||||
|
||||
}
|
||||
if (nCurrApp==52)
|
||||
{
|
||||
nCurrApp=12;
|
||||
|
||||
}
|
||||
if (nCurrApp==53)
|
||||
{
|
||||
nCurrApp=13;
|
||||
|
||||
}
|
||||
|
||||
if (nCurrApp==101)
|
||||
{
|
||||
nCurrApp=41;
|
||||
|
||||
}
|
||||
if (nCurrApp==102)
|
||||
{
|
||||
nCurrApp=42;
|
||||
|
||||
}
|
||||
if (nCurrApp==103)
|
||||
{
|
||||
nCurrApp=43;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//SpeakString("DEBUG New: "+IntToString(nCurrApp));
|
||||
|
||||
object oNew = CopyItemAndModify(oItem, ITEM_APPR_TYPE_SIMPLE_MODEL, 0, nCurrApp, TRUE);
|
||||
|
||||
if (oNew != OBJECT_INVALID)
|
||||
{
|
||||
if( bDestroyOldOnSuccess )
|
||||
{
|
||||
DestroyObject(oItem);
|
||||
}
|
||||
SetLocalInt(oNew,"jw_craft_copy",TRUE);
|
||||
return oNew;
|
||||
}
|
||||
// Safety fallback, return old helmet on failures
|
||||
|
||||
return oItem;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Returns a new helmet
|
||||
object JWGetModifiedHelmet (object oItem, int nMode, int bDestroyOldOnSuccess)
|
||||
{
|
||||
int nCurrApp = GetItemAppearance(oItem, ITEM_APPR_TYPE_ARMOR_MODEL, 0);
|
||||
int nMin = 1;
|
||||
int nMax = StringToInt(Get2DAString("baseitems", "MaxRange", BASE_ITEM_HELMET));
|
||||
|
||||
if (nMode == X2_IP_ARMORTYPE_NEXT) {
|
||||
if (++nCurrApp>nMax) nCurrApp = nMin;
|
||||
} else {
|
||||
if (--nCurrApp<nMin) nCurrApp = nMax;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Banned stuff
|
||||
/*
|
||||
if (nCurrApp==11||nCurrApp==12)
|
||||
{
|
||||
if (GetIsDM(OBJECT_SELF)||GetIsDMPossessed(OBJECT_SELF))
|
||||
{
|
||||
FloatingTextStringOnCreature("This design is not craftable by players",OBJECT_SELF,FALSE);
|
||||
}
|
||||
else if (nMode == X2_IP_ARMORTYPE_NEXT)
|
||||
{
|
||||
nCurrApp=13;
|
||||
}
|
||||
else
|
||||
{
|
||||
nCurrApp=10;
|
||||
}
|
||||
}
|
||||
|
||||
if (nCurrApp==15||nCurrApp==24||nCurrApp==26||nCurrApp==30||nCurrApp==32)
|
||||
{
|
||||
if (GetIsDM(OBJECT_SELF)||GetIsDMPossessed(OBJECT_SELF))
|
||||
{
|
||||
FloatingTextStringOnCreature("This design is not craftable by players",OBJECT_SELF,FALSE);
|
||||
}
|
||||
else if (nMode == X2_IP_ARMORTYPE_NEXT)
|
||||
{
|
||||
nCurrApp=nCurrApp+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
nCurrApp=nCurrApp-1;
|
||||
}
|
||||
}
|
||||
|
||||
// round the clock
|
||||
if (nCurrApp==33)
|
||||
{
|
||||
nCurrApp=1;
|
||||
|
||||
}
|
||||
|
||||
if (nCurrApp==50)
|
||||
{
|
||||
if (GetIsDM(OBJECT_SELF)||GetIsDMPossessed(OBJECT_SELF))
|
||||
{
|
||||
nCurrApp=32;
|
||||
}
|
||||
else
|
||||
{
|
||||
nCurrApp=31;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//SpeakString("DEBUG New: "+IntToString(nCurrApp));
|
||||
*/
|
||||
|
||||
object oNew = CopyItemAndModify(oItem, ITEM_APPR_TYPE_ARMOR_MODEL, 0, nCurrApp, TRUE);
|
||||
|
||||
if (oNew != OBJECT_INVALID)
|
||||
{
|
||||
if( bDestroyOldOnSuccess )
|
||||
{
|
||||
DestroyObject(oItem);
|
||||
}
|
||||
SetLocalInt(oNew,"jw_craft_copy",TRUE);
|
||||
return oNew;
|
||||
}
|
||||
// Safety fallback, return old helmet on failures
|
||||
|
||||
return oItem;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Returns a new shield
|
||||
object JWGetModifiedShield (object oItem, int nMode, int bDestroyOldOnSuccess)
|
||||
{
|
||||
int nCurrApp = GetItemAppearance(oItem, ITEM_APPR_TYPE_SIMPLE_MODEL, 0);
|
||||
int nBaseType = GetBaseItemType(oItem);
|
||||
int nMod = (nCurrApp/10)*10;
|
||||
nCurrApp-= nMod;
|
||||
int nMin = StringToInt(Get2DAString("baseitems", "MinRange", nBaseType));
|
||||
int nMax = (StringToInt(Get2DAString("baseitems", "MaxRange", nBaseType)) /10)*10;
|
||||
|
||||
if (nMode == X2_IP_ARMORTYPE_NEXT) {
|
||||
nMod+=10;
|
||||
if (nMod>nMax) nMod = nMin;
|
||||
} else {
|
||||
nMod-=10;
|
||||
if (nMod<nMin) nMod = nMax;
|
||||
}
|
||||
nCurrApp += nMod;
|
||||
|
||||
// round the clock
|
||||
if (nCurrApp==51)
|
||||
{
|
||||
nCurrApp=11;
|
||||
|
||||
}
|
||||
if (nCurrApp==52)
|
||||
{
|
||||
nCurrApp=12;
|
||||
|
||||
}
|
||||
if (nCurrApp==53)
|
||||
{
|
||||
nCurrApp=13;
|
||||
|
||||
}
|
||||
|
||||
if (nCurrApp==101)
|
||||
{
|
||||
nCurrApp=41;
|
||||
|
||||
}
|
||||
if (nCurrApp==102)
|
||||
{
|
||||
nCurrApp=42;
|
||||
|
||||
}
|
||||
if (nCurrApp==103)
|
||||
{
|
||||
nCurrApp=43;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//SpeakString("DEBUG New: "+IntToString(nCurrApp));
|
||||
|
||||
object oNew = CopyItemAndModify(oItem, ITEM_APPR_TYPE_SIMPLE_MODEL, 0, nCurrApp, TRUE);
|
||||
|
||||
if (oNew != OBJECT_INVALID)
|
||||
{
|
||||
if( bDestroyOldOnSuccess )
|
||||
{
|
||||
DestroyObject(oItem);
|
||||
}
|
||||
SetLocalInt(oNew,"jw_craft_copy",TRUE);
|
||||
return oNew;
|
||||
}
|
||||
// Safety fallback, return old helmet on failures
|
||||
|
||||
return oItem;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// - private -
|
||||
// Reverses a : seperated stringlist
|
||||
string CEP_ListReverse(string s)
|
||||
{
|
||||
string sCache;
|
||||
int n;
|
||||
int l = GetStringLength(s);
|
||||
s = GetSubString(s, 1, l);
|
||||
while (s!="") {
|
||||
// take string upto next seperator and put this in front of cache
|
||||
n = FindSubString(s, ":")+1;
|
||||
sCache = GetStringLeft(s, n) + sCache;
|
||||
s = GetSubString(s, n, l);
|
||||
}
|
||||
return ":"+sCache;
|
||||
}
|
||||
|
||||
// - private -
|
||||
// Prereads the 2da-file for nPart and puts all used ID's in a : seperated stringlist
|
||||
string GetCEP2DAStuff(int nPart)
|
||||
{
|
||||
// pick the right 2da to read the parts from
|
||||
string s2DA = "parts_robe";
|
||||
|
||||
|
||||
string sCache= ":";
|
||||
string sLine;
|
||||
// get the maxID used (not the amount of ID's !!!)
|
||||
//int nMax = StringToInt(Get2DAString("des_crft_aparts", "NumParts", nPart));
|
||||
//Note from Loki: Below line changed to make use of
|
||||
//backward compatibility function. Was previously the
|
||||
//preceding line.
|
||||
int nMax = 255;
|
||||
int n=1;
|
||||
while (n<=nMax) {
|
||||
// Verify validity of the ID and add to the list
|
||||
sLine = Get2DAString(s2DA, "ACBONUS", n);
|
||||
if (sLine!="") {
|
||||
sCache+= IntToString(n)+":";
|
||||
}
|
||||
n++;
|
||||
}
|
||||
// Store the list in a modulestring, once normal, once reversed, both with ID 0 added as first index for cycling
|
||||
SetLocalString(GetModule(), "ZEP_IDPreRead_"+IntToString(nPart), ":0"+sCache);
|
||||
SetLocalString(GetModule(), "ZEP_IDPreReadR_"+IntToString(nPart),
|
||||
|
||||
":0"+CEP_ListReverse(sCache));
|
||||
return sCache;
|
||||
}
|
||||
|
||||
// Returns a new robe
|
||||
object JWGetModifiedRobe (object oItem, int nMode, int bDestroyOldOnSuccess)
|
||||
{
|
||||
int nCurrApp = GetItemAppearance(oItem, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_ROBE);
|
||||
|
||||
SpeakString("Start app is "+IntToString(nCurrApp));
|
||||
|
||||
int nPart=ITEM_APPR_ARMOR_MODEL_ROBE;
|
||||
|
||||
string sPreRead = GetLocalString(GetModule(), "ZEP_IDPreRead_"+IntToString(nPart));
|
||||
if (sPreRead=="") // list didn't exist yet, so generate it
|
||||
sPreRead = GetCEP2DAStuff(nPart);
|
||||
if (nMode==X2_IP_ARMORTYPE_PREV)
|
||||
{
|
||||
sPreRead = GetLocalString(GetModule(), "ZEP_IDPreReadR_"+IntToString(nPart));
|
||||
}
|
||||
|
||||
// Find the current ID in the stringlist and pick the one coming after that
|
||||
string sID;
|
||||
string sCurrApp = IntToString(nCurrApp);
|
||||
int n = FindSubString(sPreRead, ":"+sCurrApp+":");
|
||||
sID = GetSubString(sPreRead, n+GetStringLength(sCurrApp)+2, 5);
|
||||
n = FindSubString(sID, ":");
|
||||
sID = GetStringLeft(sID, n);
|
||||
|
||||
SpeakString("Start app is "+IntToString(nCurrApp));
|
||||
|
||||
nCurrApp = StringToInt(sID);
|
||||
|
||||
SpeakString("End app is "+IntToString(nCurrApp));
|
||||
|
||||
//SpeakString("DEBUG New: "+IntToString(nCurrApp));
|
||||
|
||||
object oNew = CopyItemAndModify(oItem, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_ROBE, nCurrApp, TRUE);
|
||||
|
||||
if (oNew != OBJECT_INVALID)
|
||||
{
|
||||
if( bDestroyOldOnSuccess )
|
||||
{
|
||||
DestroyObject(oItem);
|
||||
}
|
||||
SetLocalInt(oNew,"jw_craft_copy",TRUE);
|
||||
return oNew;
|
||||
}
|
||||
// Safety fallback, return old helmet on failures
|
||||
|
||||
return oItem;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user