//::////////////////////////////////////////////////// //:: jw_treasure_gene.nss //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// // * // Takes oShield and creates a random shield of the same type // (ie small, large, tower) object CreateRandomShield(object oShield); void GenerateChestOpenedTreasure(object oChest=OBJECT_SELF); void GenerateMonsterTreasure(object oMob=OBJECT_SELF); // Gets the res ref of a random level 3 technique string GetLevel3Technique(); // gets the resf ref of a random level 4 technique string GetLevel4Technique(); // gets the resf ref of a random level 5 technique string GetLevel5Technique(); // gets the resf ref of a random level 6 technique string GetLevel6Technique(); // gets the resf ref of a random level 7 technique string GetLevel7Technique(); //Gets the res ref of random trap component string GetTrapComponent(); // Gets a random low scroll of levels 0 to 3 string GetLowLevelScroll(); // Gets a random low scroll of levels 4 to 6 string GetMidLevelScroll(); // Gets a random scroll of levels 7 to 9 string GetHighLevelScroll(); // Gets a random item players can use string GetLowLevelToys(); // Gets a random item players can use string GetHighLevelToys(); // Gets golem items, including the book string GetGolemItems(); // Gets low level cash loot, including gems string GetLowLevelCash(); // Gets medium Level cash loot, including gems string GetMediumLevelCash(); // Gets high level cash loot string GetHighLevelCash(); // Gets low level potion string GetLowLevelPotion(); // Gets medium level potion string GetMediumLevelPotion(); // Gets high level potion string GetHighLevelPotion(); // Gets general junk string GetGeneralJunk(); // Gets a random drink string GetDrink(); // Generates one item of suitable chest treasure based on the level, which should be 1 to 4 string GenerateOneChestTreasure(int nLevel); // Returns one suitable technique based on nLevel, 1 to 4; string GetSuitableTechnique(int nLevel); // Returns one scroll technique based on nLevel, 1 to 4; string GetSuitableScroll(int nLevel); // Returns one potion based on nLevel, 1 to 4; string GetSuitablePotion(int nLevel); // Returns one cash loot based on nLevel, 1 to 4; string GetSuitableCash(int nLevel); // Returns one cash loot based on nLevel, 1 to 4; string GetSuitableToy(int nLevel); // Generates one suitable item of monster treasure based on the level string GenerateOneMobTreasure(int nLevel); // Generates a shield - small, large, tower string GetShield(); // Testing script for a chest which creates shields void TestCreatesRandomShield(); #include "prc_inc_racial" object CreateRandomShield(object oShield) { int nBaseType = GetBaseItemType(oShield); int RandomShieldModel; int nRandom; // Small shields if (nBaseType==BASE_ITEM_SMALLSHIELD) { nRandom=Random(22)+1; switch (nRandom) { case 1: RandomShieldModel=11; break; case 2: RandomShieldModel=12; break; case 3: RandomShieldModel=13; break; case 4: RandomShieldModel=21; break; case 5: RandomShieldModel=22; break; case 6: RandomShieldModel=23; break; case 7: RandomShieldModel=31; break; case 8: RandomShieldModel=32; break; case 9: RandomShieldModel=33; break; case 10: RandomShieldModel=41; break; case 11: RandomShieldModel=42; break; case 12: RandomShieldModel=43; break; case 13: RandomShieldModel=51; break; case 14: RandomShieldModel=52; break; case 15: RandomShieldModel=53; break; case 16: RandomShieldModel=54; break; case 17: RandomShieldModel=55; break; case 18: RandomShieldModel=56; break; case 19: RandomShieldModel=57; break; case 20: RandomShieldModel=86; break; case 21: RandomShieldModel=87; break; case 22: RandomShieldModel=88; break; } } // End small shields // large shields else if (nBaseType==BASE_ITEM_LARGESHIELD) { // One in ten chance of boring shield if (d10()==1) { nRandom=Random(12)+1; switch (nRandom) { case 1: RandomShieldModel=11; break; case 2: RandomShieldModel=12; break; case 3: RandomShieldModel=13; break; case 4: RandomShieldModel=21; break; case 5: RandomShieldModel=22; break; case 6: RandomShieldModel=23; break; case 7: RandomShieldModel=31; break; case 8: RandomShieldModel=32; break; case 9: RandomShieldModel=33; break; case 10: RandomShieldModel=41; break; case 11: RandomShieldModel=42; break; case 12: RandomShieldModel=43; break; } } // end boring shields else { RandomShieldModel=Random(205)+51; } while(RandomShieldModel==096)// (ik 18/06/05) blocks bad large shield model RandomShieldModel=Random(205)+51; } // END LARGE SHIELDS // End small shields // large shields else if (nBaseType==BASE_ITEM_TOWERSHIELD) { // One in ten chance of boring shield if (d10()==1) { nRandom=Random(12)+1; switch (nRandom) { case 1: RandomShieldModel=11; break; case 2: RandomShieldModel=12; break; case 3: RandomShieldModel=13; break; case 4: RandomShieldModel=21; break; case 5: RandomShieldModel=22; break; case 6: RandomShieldModel=23; break; case 7: RandomShieldModel=31; break; case 8: RandomShieldModel=32; break; case 9: RandomShieldModel=33; break; case 10: RandomShieldModel=41; break; case 11: RandomShieldModel=42; break; case 12: RandomShieldModel=43; break; } } // end boring shields else if (d3()!=1) { RandomShieldModel=Random(103)+51; } else { RandomShieldModel=Random(49)+181; } while(RandomShieldModel==145||RandomShieldModel==67||RandomShieldModel==61||RandomShieldModel==194) // (ik 18/06/05) blocks bad towershield models RandomShieldModel=Random(103)+51; } object oNew = CopyItemAndModify(oShield, ITEM_APPR_TYPE_SIMPLE_MODEL, 0, RandomShieldModel, TRUE); if (GetIsObjectValid(oNew)) { DestroyObject(oShield); return oNew; } else { return oShield; } } string GetShield() { string sString; int nRandom=d100(); if (nRandom<50) { sString="jw_small_shield"; } else if (nRandom<80) { sString="jw_large_shield"; } else { sString="jw_tower_shield"; } return sString; } string GetSuitableToy(int nLevel) { string sString; int nRandom=d100(); if (nLevel==1) { if (nRandom<90) { sString=GetLowLevelToys(); } else { sString=GetHighLevelToys(); } } else if (nLevel==2) { if (nRandom<70) { sString=GetLowLevelToys(); } else { sString=GetHighLevelToys(); } } else if (nLevel==3) { if (nRandom<50) { sString=GetLowLevelToys(); } else { sString=GetHighLevelToys(); } } else { if (nRandom<30) { sString=GetLowLevelToys(); } else { sString=GetHighLevelToys(); } } return sString; } string GetSuitableCash(int nLevel) { string sString; int nRandom=d100(); if (nLevel==1) { if (nRandom<70) { sString=GetLowLevelCash(); } else { sString=GetMediumLevelCash(); } } else if (nLevel==2) { if (nRandom<40) { sString=GetLowLevelCash(); } else if (nRandom<80) { sString=GetMediumLevelCash(); } else { sString=GetHighLevelCash(); } } else if (nLevel==3) { if (nRandom<20) { sString=GetLowLevelCash(); } else if (nRandom<75) { sString=GetMediumLevelCash(); } else { sString=GetHighLevelCash(); } } else { if (nRandom<50) { sString=GetMediumLevelCash(); } else { sString=GetHighLevelCash(); } } return sString; } string GetSuitablePotion(int nLevel) { string sString; int nRandom=d100(); if (nLevel==1) { if (nRandom<70) { sString=GetLowLevelPotion(); } else { sString=GetMediumLevelPotion(); } } else if (nLevel==2) { if (nRandom<40) { sString=GetLowLevelPotion(); } else if (nRandom<80) { sString=GetMediumLevelPotion(); } else { sString=GetHighLevelPotion(); } } else if (nLevel==3) { if (nRandom<20) { sString=GetLowLevelPotion(); } else if (nRandom<75) { sString=GetMediumLevelPotion(); } else { sString=GetHighLevelPotion(); } } else { if (nRandom<10) { sString=GetLowLevelPotion(); } else if (nRandom<70) { sString=GetMediumLevelPotion(); } else { sString=GetHighLevelPotion(); } } return sString; } string GetSuitableScroll(int nLevel) { string sString; int nRandom=d100(); if (nLevel==1) { if (nRandom<70) { sString=GetLowLevelScroll(); } else { sString=GetMidLevelScroll(); } } else if (nLevel==2) { if (nRandom<40) { sString=GetLowLevelScroll(); } else if (nRandom<80) { sString=GetMidLevelScroll(); } else { sString=GetHighLevelScroll(); } } else if (nLevel==3) { if (nRandom<20) { sString=GetLowLevelScroll(); } else if (nRandom<75) { sString=GetMidLevelScroll(); } else { sString=GetHighLevelScroll(); } } else { if (nRandom<10) { sString=GetLowLevelScroll(); } else if (nRandom<70) { sString=GetMidLevelScroll(); } else { sString=GetHighLevelScroll(); } } return sString; } string GetSuitableTechnique(int nLevel) { string sString; int nRandom=d100(); if (nLevel==1) { sString=GetLevel3Technique(); } else if (nLevel==2) { if (nRandom<80) { sString=GetLevel3Technique(); } else { sString=GetLevel4Technique(); } } else if (nLevel==3) { if (nRandom<70) { sString=GetLevel3Technique(); } else if (nRandom<90) { sString=GetLevel4Technique(); } else { sString=GetLevel5Technique(); } } else { if (nRandom<60) { sString=GetLevel3Technique(); } else if (nRandom<84) { sString=GetLevel4Technique(); } else if (nRandom<94) { sString=GetLevel5Technique(); } else if (nRandom<98) { sString=GetLevel6Technique(); } else { sString=GetLevel7Technique(); } } return sString; } string GetLevel3Technique() { string sString; int nRandom=Random(126)+1; switch (nRandom) { case 1: sString="jw_pat_wep_007"; break; case 2: sString="jw_pat_wep_011"; break; case 3: sString="jw_pat_wep_013"; break; case 4: sString="jw_pat_wep_014"; break; case 5: sString="jw_pat_wep_019"; break; case 6: sString="jw_pat_wep_021"; break; case 7: sString="jw_pat_wep_022"; break; case 8: sString="jw_pat_wep_025"; break; case 9: sString="jw_pat_wep_026"; break; case 10: sString="jw_pat_wep_028"; break; case 11: sString="jw_pat_wep_035"; break; case 12: sString="jw_pat_wep_037"; break; case 13: sString="jw_pat_wep_038"; break; case 14: sString="jw_pat_wep_041"; break; case 15: sString="jw_pat_wep_042"; break; case 16: sString="jw_pat_wep_044"; break; case 17: sString="jw_pat_wep_049"; break; case 18: sString="jw_pat_wep_050"; break; case 19: sString="jw_pat_wep_052"; break; case 20: sString="jw_pat_wep_056"; break; case 21: sString="jw_pat_wep_067"; break; case 22: sString="jw_pat_wep_069"; break; case 23: sString="jw_pat_wep_070"; break; case 24: sString="jw_pat_wep_073"; break; case 25: sString="jw_pat_wep_074"; break; case 26: sString="jw_pat_wep_076"; break; case 27: sString="jw_pat_wep_081"; break; case 28: sString="jw_pat_wep_082"; break; case 29: sString="jw_pat_wep_084"; break; case 30: sString="jw_pat_wep_088"; break; case 31: sString="jw_pat_wep_097"; break; case 32: sString="jw_pat_wep_098"; break; case 33: sString="jw_pat_wep_100"; break; case 34: sString="jw_pat_wep_104"; break; case 35: sString="jw_pat_wep_112"; break; case 36: sString="jw_pat_arm_011"; break; case 37: sString="jw_pat_arm_013"; break; case 38: sString="jw_pat_arm_014"; break; case 39: sString="jw_pat_arm_019"; break; case 40: sString="jw_pat_arm_021"; break; case 41: sString="jw_pat_arm_022"; break; case 42: sString="jw_pat_arm_025"; break; case 43: sString="jw_pat_arm_026"; break; case 44: sString="jw_pat_arm_028"; break; case 45: sString="jw_pat_arm_035"; break; case 46: sString="jw_pat_arm_037"; break; case 47: sString="jw_pat_arm_038"; break; case 48: sString="jw_pat_arm_041"; break; case 49: sString="jw_pat_arm_042"; break; case 50: sString="jw_pat_arm_044"; break; case 51: sString="jw_pat_arm_049"; break; case 52: sString="jw_pat_arm_050"; break; case 53: sString="jw_pat_arm_052"; break; case 54: sString="jw_pat_arm_056"; break; case 55: sString="jw_pat_arm_067"; break; case 56: sString="jw_pat_arm_069"; break; case 57: sString="jw_pat_arm_070"; break; case 58: sString="jw_pat_arm_073"; break; case 59: sString="jw_pat_arm_074"; break; case 60: sString="jw_pat_arm_076"; break; case 61: sString="jw_pat_arm_081"; break; case 62: sString="jw_pat_arm_082"; break; case 63: sString="jw_pat_arm_084"; break; case 64: sString="jw_pat_arm_088"; break; case 65: sString="jw_pat_arm_097"; break; case 66: sString="jw_pat_arm_098"; break; case 67: sString="jw_pat_arm_100"; break; case 68: sString="jw_pat_arm_104"; break; case 69: sString="jw_pat_arm_112"; break; case 70: sString="jw_pat_rin_007"; break; case 71: sString="jw_pat_rin_011"; break; case 72: sString="jw_pat_rin_013"; break; case 73: sString="jw_pat_rin_014"; break; case 74: sString="jw_pat_rin_019"; break; case 75: sString="jw_pat_rin_021"; break; case 76: sString="jw_pat_rin_022"; break; case 77: sString="jw_pat_rin_025"; break; case 78: sString="jw_pat_rin_026"; break; case 79: sString="jw_pat_rin_028"; break; case 80: sString="jw_pat_rin_035"; break; case 81: sString="jw_pat_rin_037"; break; case 82: sString="jw_pat_rin_038"; break; case 83: sString="jw_pat_rin_041"; break; case 84: sString="jw_pat_rin_042"; break; case 85: sString="jw_pat_rin_044"; break; case 86: sString="jw_pat_rin_049"; break; case 87: sString="jw_pat_rin_050"; break; case 88: sString="jw_pat_rin_052"; break; case 89: sString="jw_pat_rin_056"; break; case 90: sString="jw_pat_rin_067"; break; case 91: sString="jw_pat_rin_069"; break; case 92: sString="jw_pat_rin_070"; break; case 93: sString="jw_pat_rin_073"; break; case 94: sString="jw_pat_rin_074"; break; case 95: sString="jw_pat_rin_076"; break; case 96: sString="jw_pat_rin_081"; break; case 97: sString="jw_pat_rin_082"; break; case 98: sString="jw_pat_rin_084"; break; case 99: sString="jw_pat_rin_088"; break; case 100: sString="jw_pat_rin_097"; break; case 101: sString="jw_pat_rin_098"; break; case 102: sString="jw_pat_rin_100"; break; case 103: sString="jw_pat_rin_104"; break; case 104: sString="jw_pat_rin_112"; break; case 105: sString="jw_pat_clo_007"; break; case 106: sString="jw_pat_clo_011"; break; case 107: sString="jw_pat_clo_013"; break; case 108: sString="jw_pat_clo_014"; break; case 109: sString="jw_pat_clo_019"; break; case 110: sString="jw_pat_clo_021"; break; case 111: sString="jw_pat_clo_022"; break; case 112: sString="jw_pat_clo_025"; break; case 113: sString="jw_pat_clo_026"; break; case 114: sString="jw_pat_clo_028"; break; case 115: sString="jw_pat_clo_035"; break; case 116: sString="jw_pat_clo_037"; break; case 117: sString="jw_pat_clo_038"; break; case 118: sString="jw_pat_clo_041"; break; case 119: sString="jw_pat_clo_042"; break; case 120: sString="jw_pat_clo_044"; break; case 121: sString="jw_pat_clo_049"; break; case 122: sString="jw_pat_gau_007"; break; case 123: sString="jw_pat_gau_011"; break; case 124: sString="jw_pat_gau_013"; break; case 125: sString="jw_pat_gau_014"; break; case 126: sString="jw_pat_arm_007"; break; } return sString; } string GetLevel4Technique() { string sString; int nRandom=Random(129)+1; switch (nRandom) { case 1: sString="jw_pat_wep_015"; break; case 2: sString="jw_pat_wep_023"; break; case 3: sString="jw_pat_wep_027"; break; case 4: sString="jw_pat_wep_029"; break; case 5: sString="jw_pat_wep_030"; break; case 6: sString="jw_pat_wep_039"; break; case 7: sString="jw_pat_wep_043"; break; case 8: sString="jw_pat_wep_045"; break; case 9: sString="jw_pat_wep_046"; break; case 10: sString="jw_pat_wep_051"; break; case 11: sString="jw_pat_wep_053"; break; case 12: sString="jw_pat_wep_054"; break; case 13: sString="jw_pat_wep_057"; break; case 14: sString="jw_pat_wep_058"; break; case 15: sString="jw_pat_wep_060"; break; case 16: sString="jw_pat_wep_071"; break; case 17: sString="jw_pat_wep_075"; break; case 18: sString="jw_pat_wep_077"; break; case 19: sString="jw_pat_wep_078"; break; case 20: sString="jw_pat_wep_083"; break; case 21: sString="jw_pat_wep_085"; break; case 22: sString="jw_pat_wep_086"; break; case 23: sString="jw_pat_wep_089"; break; case 24: sString="jw_pat_wep_090"; break; case 25: sString="jw_pat_wep_092"; break; case 26: sString="jw_pat_wep_099"; break; case 27: sString="jw_pat_wep_101"; break; case 28: sString="jw_pat_wep_102"; break; case 29: sString="jw_pat_wep_105"; break; case 30: sString="jw_pat_wep_106"; break; case 31: sString="jw_pat_wep_108"; break; case 32: sString="jw_pat_wep_113"; break; case 33: sString="jw_pat_wep_114"; break; case 34: sString="jw_pat_wep_115"; break; case 35: sString="jw_pat_wep_116"; break; case 36: sString="jw_pat_wep_120"; break; case 37: sString="jw_pat_arm_015"; break; case 38: sString="jw_pat_arm_023"; break; case 39: sString="jw_pat_arm_027"; break; case 40: sString="jw_pat_arm_029"; break; case 41: sString="jw_pat_arm_030"; break; case 42: sString="jw_pat_arm_039"; break; case 43: sString="jw_pat_arm_043"; break; case 44: sString="jw_pat_arm_045"; break; case 45: sString="jw_pat_arm_046"; break; case 46: sString="jw_pat_arm_051"; break; case 47: sString="jw_pat_arm_053"; break; case 48: sString="jw_pat_arm_054"; break; case 49: sString="jw_pat_arm_057"; break; case 50: sString="jw_pat_arm_058"; break; case 51: sString="jw_pat_arm_060"; break; case 52: sString="jw_pat_arm_071"; break; case 53: sString="jw_pat_arm_075"; break; case 54: sString="jw_pat_arm_077"; break; case 55: sString="jw_pat_arm_078"; break; case 56: sString="jw_pat_arm_083"; break; case 57: sString="jw_pat_arm_085"; break; case 58: sString="jw_pat_arm_086"; break; case 59: sString="jw_pat_arm_089"; break; case 60: sString="jw_pat_arm_090"; break; case 61: sString="jw_pat_arm_092"; break; case 62: sString="jw_pat_arm_099"; break; case 63: sString="jw_pat_arm_101"; break; case 64: sString="jw_pat_arm_102"; break; case 65: sString="jw_pat_arm_105"; break; case 66: sString="jw_pat_arm_106"; break; case 67: sString="jw_pat_arm_108"; break; case 68: sString="jw_pat_arm_113"; break; case 69: sString="jw_pat_arm_114"; break; case 70: sString="jw_pat_arm_115"; break; case 71: sString="jw_pat_arm_116"; break; case 72: sString="jw_pat_arm_120"; break; case 73: sString="jw_pat_rin_015"; break; case 74: sString="jw_pat_rin_023"; break; case 75: sString="jw_pat_rin_027"; break; case 76: sString="jw_pat_rin_029"; break; case 77: sString="jw_pat_rin_030"; break; case 78: sString="jw_pat_rin_039"; break; case 79: sString="jw_pat_rin_043"; break; case 80: sString="jw_pat_rin_045"; break; case 81: sString="jw_pat_rin_046"; break; case 82: sString="jw_pat_rin_051"; break; case 83: sString="jw_pat_rin_053"; break; case 84: sString="jw_pat_rin_054"; break; case 85: sString="jw_pat_rin_057"; break; case 86: sString="jw_pat_rin_058"; break; case 87: sString="jw_pat_rin_060"; break; case 88: sString="jw_pat_rin_071"; break; case 89: sString="jw_pat_rin_075"; break; case 90: sString="jw_pat_rin_077"; break; case 91: sString="jw_pat_rin_078"; break; case 92: sString="jw_pat_rin_083"; break; case 93: sString="jw_pat_rin_085"; break; case 94: sString="jw_pat_rin_086"; break; case 95: sString="jw_pat_rin_089"; break; case 96: sString="jw_pat_rin_090"; break; case 97: sString="jw_pat_rin_092"; break; case 98: sString="jw_pat_rin_099"; break; case 99: sString="jw_pat_rin_101"; break; case 100: sString="jw_pat_rin_102"; break; case 101: sString="jw_pat_rin_105"; break; case 102: sString="jw_pat_rin_106"; break; case 103: sString="jw_pat_rin_108"; break; case 104: sString="jw_pat_rin_113"; break; case 105: sString="jw_pat_rin_114"; break; case 106: sString="jw_pat_rin_115"; break; case 107: sString="jw_pat_rin_116"; break; case 108: sString="jw_pat_rin_120"; break; case 109: sString="jw_pat_clo_015"; break; case 110: sString="jw_pat_clo_023"; break; case 111: sString="jw_pat_clo_027"; break; case 112: sString="jw_pat_clo_029"; break; case 113: sString="jw_pat_clo_030"; break; case 114: sString="jw_pat_clo_039"; break; case 115: sString="jw_pat_clo_043"; break; case 116: sString="jw_pat_clo_045"; break; case 117: sString="jw_pat_clo_046"; break; case 118: sString="jw_pat_clo_051"; break; case 119: sString="jw_pat_clo_053"; break; case 120: sString="jw_pat_clo_054"; break; case 121: sString="jw_pat_clo_057"; break; case 122: sString="jw_pat_clo_058"; break; case 123: sString="jw_pat_clo_060"; break; case 124: sString="jw_pat_clo_071"; break; case 125: sString="jw_pat_clo_075"; break; case 126: sString="jw_pat_gau_015"; break; case 127: sString="jw_pat_gau_023"; break; case 128: sString="jw_pat_gau_027"; break; case 129: sString="jw_pat_gau_029"; break; } return sString; } string GetLevel5Technique() { string sString; int nRandom=Random(72)+1; switch (nRandom) { case 1: sString="jw_pat_wep_031"; break; case 2: sString="jw_pat_wep_047"; break; case 3: sString="jw_pat_wep_055"; break; case 4: sString="jw_pat_wep_059"; break; case 5: sString="jw_pat_wep_061"; break; case 6: sString="jw_pat_wep_062"; break; case 7: sString="jw_pat_wep_079"; break; case 8: sString="jw_pat_wep_087"; break; case 9: sString="jw_pat_wep_091"; break; case 10: sString="jw_pat_wep_093"; break; case 11: sString="jw_pat_wep_094"; break; case 12: sString="jw_pat_wep_103"; break; case 13: sString="jw_pat_wep_107"; break; case 14: sString="jw_pat_wep_109"; break; case 15: sString="jw_pat_wep_110"; break; case 16: sString="jw_pat_wep_117"; break; case 17: sString="jw_pat_wep_118"; break; case 18: sString="jw_pat_wep_121"; break; case 19: sString="jw_pat_wep_122"; break; case 20: sString="jw_pat_wep_124"; break; case 21: sString="jw_pat_arm_031"; break; case 22: sString="jw_pat_arm_047"; break; case 23: sString="jw_pat_arm_055"; break; case 24: sString="jw_pat_arm_059"; break; case 25: sString="jw_pat_arm_061"; break; case 26: sString="jw_pat_arm_062"; break; case 27: sString="jw_pat_arm_079"; break; case 28: sString="jw_pat_arm_087"; break; case 29: sString="jw_pat_arm_091"; break; case 30: sString="jw_pat_arm_093"; break; case 31: sString="jw_pat_arm_094"; break; case 32: sString="jw_pat_arm_103"; break; case 33: sString="jw_pat_arm_107"; break; case 34: sString="jw_pat_arm_109"; break; case 35: sString="jw_pat_arm_110"; break; case 36: sString="jw_pat_arm_117"; break; case 37: sString="jw_pat_arm_118"; break; case 38: sString="jw_pat_arm_121"; break; case 39: sString="jw_pat_arm_122"; break; case 40: sString="jw_pat_arm_124"; break; case 41: sString="jw_pat_rin_031"; break; case 42: sString="jw_pat_rin_047"; break; case 43: sString="jw_pat_rin_055"; break; case 44: sString="jw_pat_rin_059"; break; case 45: sString="jw_pat_rin_061"; break; case 46: sString="jw_pat_rin_062"; break; case 47: sString="jw_pat_rin_079"; break; case 48: sString="jw_pat_rin_087"; break; case 49: sString="jw_pat_rin_091"; break; case 50: sString="jw_pat_rin_093"; break; case 51: sString="jw_pat_rin_094"; break; case 52: sString="jw_pat_rin_103"; break; case 53: sString="jw_pat_rin_107"; break; case 54: sString="jw_pat_rin_109"; break; case 55: sString="jw_pat_rin_110"; break; case 56: sString="jw_pat_rin_117"; break; case 57: sString="jw_pat_rin_118"; break; case 58: sString="jw_pat_rin_121"; break; case 59: sString="jw_pat_rin_122"; break; case 60: sString="jw_pat_rin_124"; break; case 61: sString="jw_pat_clo_031"; break; case 62: sString="jw_pat_clo_047"; break; case 63: sString="jw_pat_clo_055"; break; case 64: sString="jw_pat_clo_059"; break; case 65: sString="jw_pat_clo_061"; break; case 66: sString="jw_pat_clo_062"; break; case 67: sString="jw_pat_clo_079"; break; case 68: sString="jw_pat_clo_087"; break; case 69: sString="jw_pat_gau_031"; break; case 70: sString="jw_pat_gau_047"; break; case 71: sString="jw_pat_gau_055"; break; case 72: sString="jw_pat_gau_059"; break; } return sString; } string GetLevel6Technique() { string sString; int nRandom=Random(27)+1; switch (nRandom) { case 1: sString="jw_pat_wep_063"; break; case 2: sString="jw_pat_wep_095"; break; case 3: sString="jw_pat_wep_111"; break; case 4: sString="jw_pat_wep_110"; break; case 5: sString="jw_pat_wep_123"; break; case 6: sString="jw_pat_wep_125"; break; case 7: sString="jw_pat_wep_126"; break; case 8: sString="jw_pat_arm_063"; break; case 9: sString="jw_pat_arm_095"; break; case 10: sString="jw_pat_arm_111"; break; case 11: sString="jw_pat_arm_110"; break; case 12: sString="jw_pat_arm_123"; break; case 13: sString="jw_pat_arm_125"; break; case 14: sString="jw_pat_arm_126"; break; case 15: sString="jw_pat_rin_063"; break; case 16: sString="jw_pat_rin_095"; break; case 17: sString="jw_pat_rin_111"; break; case 18: sString="jw_pat_rin_110"; break; case 19: sString="jw_pat_rin_123"; break; case 20: sString="jw_pat_rin_125"; break; case 21: sString="jw_pat_rin_126"; break; case 22: sString="jw_pat_clo_063"; break; case 23: sString="jw_pat_clo_095"; break; case 24: sString="jw_pat_clo_111"; break; case 25: sString="jw_pat_gau_063"; break; case 26: sString="jw_pat_gau_095"; break; case 27: sString="jw_pat_gau_111"; break; } return sString; } string GetLevel7Technique() { string sString; int nRandom=Random(5)+1; switch (nRandom) { case 1: sString="jw_pat_wep_127"; break; case 2: sString="jw_pat_arm_127"; break; case 3: sString="jw_pat_rin_127"; break; case 4: sString="jw_pat_clo_127"; break; case 5: sString="jw_pat_gau_127"; break; } return sString; } string GetTrapComponent() { string sString; int nRandom=Random(5)+1; switch (nRandom) { case 1: sString="etr_nature"; break; case 2: sString="etr_spike"; break; case 3: sString="etr_holy"; break; case 4: sString="etr_gas"; break; case 5: sString="etr_sonic"; break; } return sString; } string GetLowLevelScroll() { string sString; // Level is 0 to 3 int nLevel=Random(4); int nNumber; if (nLevel==0) { nNumber=Random(10)+1; } else if (nLevel==1) { nNumber=Random(40)+1; } else if (nLevel==2) { nNumber=Random(41)+1; } else if (nLevel==3) { nNumber=Random(50)+1; } sString="jw_scroll_"+IntToString(nLevel)+"_"+IntToString(nNumber); return sString; } string GetMidLevelScroll() { string sString; // Level is 4 to 6 int nLevel=Random(3)+4; int nNumber; if (nLevel==4) { nNumber=Random(29)+1; } else if (nLevel==5) { nNumber=Random(29)+1; } else if (nLevel==6) { nNumber=Random(29)+1; } sString="jw_scroll_"+IntToString(nLevel)+"_"+IntToString(nNumber); return sString; } string GetHighLevelScroll() { string sString; // Level is 7 to 9 int nLevel=Random(3)+7; int nNumber; if (nLevel==7) { nNumber=Random(17)+1; } else if (nLevel==8) { nNumber=Random(19)+1; } else if (nLevel==9) { nNumber=Random(21)+1; } sString="jw_scroll_"+IntToString(nLevel)+"_"+IntToString(nNumber); return sString; } string GetLowLevelToys() { int nRandom=Random(17)+1; string sString; switch (nRandom) { case 1: sString="jw_ioun_557"; break; case 2: sString="jw_ioun_558"; break; case 3: sString="jw_ioun_554"; break; case 4: sString="jw_ioun_555"; break; case 5: sString="jw_ioun_559"; break; case 6: sString="jw_ioun_560"; break; case 7: sString="jw_ioun_556"; break; case 8: sString="jw_dwarf_potio"; break; case 9: sString="jw_garrote1"; break; case 10: sString="jw_garrote2"; break; case 11: sString="jw_kaim"; break; case 12: sString="jw_blank_scroll"; break; case 13: sString="ccr0_xx_xx_bl_dq"; break; case 14: sString="NW_IT_PICKS001"; break; case 15: sString="NW_IT_PICKS002"; break; case 16: sString="jw_appraiser"; break; case 17: sString="ccr0_xx_xx_bl_dr"; break; } return sString; } string GetHighLevelToys() { int nRandom=Random(8)+1; string sString; switch (nRandom) { case 1: sString="jw_garrote3"; break; case 2: sString="jw_garrote4"; break; case 3: sString="jw_branc_giv"; break; case 4: sString="ccr0_xx_xx_bl_dr"; break; case 5: sString="NW_IT_PICKS003"; break; case 6: sString="jw_barb_forceb"; break; case 7: sString="jw_elis_instr"; break; case 8: sString="ccr0_xx_xx_bl_ds"; break; } return sString; } string GetGolemItems() { if (Random(150)==1) { // The book return "jw_golem_book"; } string sString; int nRandom=Random(3)+1; switch (nRandom) { case 1: sString="jw_golem_head"; break; case 2: sString="jw_golem_power"; break; case 3: sString="jw_golem_chest"; break; } return sString; } string GetLowLevelCash() { string sString; int nRandom=Random(17)+1; switch (nRandom) { case 1: sString="NW_IT_GEM007"; break; case 2: sString="NW_IT_GEM007"; break; case 3: sString="NW_IT_GEM002"; break; case 4: sString="NW_IT_GEM014"; break; case 5: sString="NW_IT_GEM004"; break; case 6: sString="NW_IT_GEM003"; break; case 7: sString="NW_IT_GEM015"; break; case 8: sString="jw_loot_9"; break; case 9: sString="jw_loot_7"; break; case 10: sString="mrxtreasure039"; break; case 11: sString="mrxtreasure027"; break; case 12: sString="mrxtreasure095"; break; case 13: sString="mrxtreasure037"; break; case 14: sString="mrxtreasure049"; break; case 15: sString="mrxtreasure056"; break; case 16: sString="mrxtreasure070"; break; case 17: sString="mrxtreasure061"; break; } return sString; } string GetMediumLevelCash() { string sString; int nRandom=Random(13)+1; switch (nRandom) { case 1: sString="NW_IT_GEM011"; break; case 2: sString="jw_loot_10"; break; case 3: sString="jw_loot_8"; break; case 4: sString="jw_loot_6"; break; case 5: sString="jw_loot_4"; break; case 6: sString="jw_loot_3"; break; case 7: sString="jw_loot_1"; break; case 8: sString="jw_100r_9"; break; case 9: sString="jw_100r_8"; break; case 10: sString="mrxtreasure013"; break; case 11: sString="mrxtreasure074"; break; case 12: sString="mrxtreasure067"; break; case 13: sString="mrxtreasure019"; break; } return sString; } string GetHighLevelCash() { string sString; int nRandom=Random(7)+1; switch (nRandom) { case 1: sString="jw_700r_9"; break; case 2: sString="jw_loot_2"; break; case 3: sString="jw_loot_5"; break; case 4: sString="jw_loot_11"; break; case 5: sString="mrxtreasure020"; break; case 6: sString="mrxtreasure041"; break; case 7: sString="mrxtreasure021"; break; } return sString; } string GetLowLevelPotion() { string sString; int nRandom=Random(12)+1; switch (nRandom) { case 1: sString="NW_IT_MPOTION020"; break; case 2: sString="NW_IT_MPOTION016"; break; case 3: sString="NW_IT_MPOTION020"; break; case 4: sString="NW_IT_MPOTION014"; break; case 5: sString="NW_IT_MPOTION010"; break; case 6: sString="NW_IT_MPOTION017"; break; case 7: sString="X2_IT_MPOTION001"; break; case 8: sString="NW_IT_MPOTION018"; break; case 9: sString="ptn_rogscunn"; break; case 10: sString="ptn_minelres"; break; case 11: sString="ptn_eavesdrop"; break; case 12: sString="ptn_drowsight"; break; } return sString; } string GetMediumLevelPotion() { string sString; int nRandom=Random(10)+1; switch (nRandom) { case 1: sString="NW_IT_MPOTION002"; break; case 2: sString="NW_IT_MPOTION005"; break; case 3: sString="NW_IT_MPOTION009"; break; case 4: sString="NW_IT_MPOTION015"; break; case 5: sString="NW_IT_MPOTION007"; break; case 6: sString="X2_IT_MPOTION002"; break; case 7: sString="ptn_negprot"; break; case 8: sString="ptn_unfettered"; break; case 9: sString="ptn_burnretort"; break; case 10: sString="ptn_displace"; break; } return sString; } string GetHighLevelPotion() { string sString; int nRandom=Random(5)+1; switch (nRandom) { case 1: sString="NW_IT_MPOTION013"; break; case 2: sString="NW_IT_MPOTION008"; break; case 3: sString="NW_IT_MPOTION004"; break; case 4: sString="ptn_firebreath"; break; case 5: sString="ptn_mystabs"; break; } return sString; } string GetGeneralJunk() { string sString; int nRandom=Random(24)+1; switch (nRandom) { case 1: sString="jw_lantern"; break; case 2: sString="jw_candle"; break; case 3: sString="jw_bard_lute"; break; case 4: sString="jw_bard_flute"; break; case 5: sString="jw_bard_tamb"; break; case 6: sString="jw_book16"; break; case 7: sString="jw_book2"; break; case 8: sString="jw_book4"; break; case 9: sString="jw_wildm_book"; break; case 10: sString="jw_dwarf_book4"; break; case 11: sString="jw_book6"; break; case 12: sString="jw_book7"; break; case 13: sString="jw_dwarf_book6"; break; case 14: sString="jw_book8"; break; case 15: sString="jw_book5"; break; case 16: sString="jw_bright_book"; break; case 17: sString="jw_waukeen_book"; break; case 18: sString="jw_dragon_book"; break; case 19: sString="jw_book_taxcol"; break; case 20: sString="jw_lootbox1"; break; case 21: sString="jw_lootbox2"; break; case 22: sString="jw_lootbox3"; break; case 23: sString="jw_battles_book"; break; case 24: sString="ccr0_xx_xx_xx_b9"; // glass bottle break; } return sString; } string GetDrink() { return "jw_drink_"+IntToString(Random(30)+1); } string GenerateOneChestTreasure(int nLevel) { string sString; int nRandom=d100(); if (nRandom<5) { sString=GetSuitableTechnique(nLevel); } else if (nRandom<10) { sString=GetGolemItems(); } else if (nRandom<14) { sString=GetTrapComponent(); } else if (nRandom<38) { sString=GetSuitableScroll(nLevel); } else if (nRandom<47) { sString=GetSuitablePotion(nLevel); } else if (nRandom<72) { sString=GetSuitableCash(nLevel); } else if (nRandom<73) { sString=GetDrink(); } else if (nRandom<78) { sString=GetGeneralJunk(); } else if (nRandom<93) { sString=GetSuitableToy(nLevel); } else { sString=GetShield(); } return sString; } string GenerateOneMobTreasure(int nLevel) { string sString; int nRandom=d100(); if (nRandom<10) { sString=GetTrapComponent(); } else if (nRandom<22) { sString=GetSuitableScroll(nLevel); } else if (nRandom<45) { sString=GetSuitablePotion(nLevel); } else if (nRandom<68) { sString=GetSuitableCash(nLevel); } else if (nRandom<70) { sString=GetDrink(); } else if (nRandom<85) { sString=GetGeneralJunk(); } else { sString=GetSuitableToy(nLevel); } return sString; } void GenerateChestOpenedTreasure(object oChest=OBJECT_SELF) { object oKiller = GetLastKiller(); if (GetIsObjectValid(oKiller) == TRUE) { // Create placeholder to stop a new chest spawning object oPlace=CreateObject(OBJECT_TYPE_PLACEABLE,"jw_placeholder",GetLocation(oChest)); SetLocalObject(GetNearestObjectByTag("jw_place_box",oChest),"placeable",oPlace); SetLocalInt(oPlace,"jw_hidden_int",TRUE); } if (GetLocalInt(oChest,"chest_done") == 1) { return; //// This chest is done, forget it } object oPC=GetLastOpenedBy(); SetLocalInt(oChest,"chest_done",1); if (d3()==1) { // empty sorry if (!GetIsObjectValid(oKiller)) { FloatingTextStringOnCreature("Empty",oPC); } return; } int nNumItems; int nDestroyed=FALSE; if (GetIsObjectValid(oKiller) == TRUE) { // * I was bashed! nDestroyed=TRUE; nNumItems=d3()+1; } else { nNumItems=d3()+3; int nSkill=GetSkillRank(SKILL_SEARCH,oPC); if (nSkill>0) { if (GetIsSkillSuccessful(oPC,SKILL_SEARCH,30)) { nNumItems=nNumItems+d3(); } } } // Finished this bit int nLevel=GetLocalInt(GetArea(oChest),"areatype"); // Dungeon 1 is 8, dungeon 4 is 11 if ((nLevel<8)||(nLevel>11)) { // We are not in a dungeon, so just return; return; } // Turn this in to one to 4 nLevel=nLevel-7; string sString; object oLoot; int nIdx; for (nIdx=1;nIdx<=nNumItems;nIdx++) { sString=GenerateOneChestTreasure(nLevel); oLoot=CreateItemOnObject(sString,oChest); int nBase=GetBaseItemType(oLoot); if (nBase==BASE_ITEM_SMALLSHIELD||nBase==BASE_ITEM_LARGESHIELD||nBase==BASE_ITEM_TOWERSHIELD) { oLoot=CreateRandomShield(oLoot); } if (!GetIsObjectValid(oLoot)) { SendMessageToAllDMs("Error in chest loot script, item "+sString+" is invalid"); } } } void GenerateMonsterTreasure(object oMob=OBJECT_SELF) { // Most mobs don't have loot if (d3()!=1) { return; } int nRace=MyPRCGetRacialType(OBJECT_SELF); if ((nRace==RACIAL_TYPE_ANIMAL)||(nRace==RACIAL_TYPE_BEAST)||(nRace==RACIAL_TYPE_OOZE)||(nRace==RACIAL_TYPE_VERMIN)||(nRace==RACIAL_TYPE_ELEMENTAL)||(nRace==RACIAL_TYPE_CONSTRUCT)||(nRace==RACIAL_TYPE_MAGICAL_BEAST)) { return; // no loot } if (GetLocalInt(oMob,"blighted")==TRUE) { // Blighted have no loot return; } int nLevel=FloatToInt(GetChallengeRating(oMob)); nLevel=nLevel-10; nLevel=nLevel/2; if (nLevel<1) { nLevel=1; } else if (nLevel>4) { nLevel=4; } string sString; object oLoot; int nNumItems=d2(); int nIdx; for (nIdx=1;nIdx<=nNumItems;nIdx++) { if (d4()==1) { GiveGoldToCreature(oMob,(d20()*nLevel)); } else { sString=GenerateOneMobTreasure(nLevel); oLoot=CreateItemOnObject(sString,oMob); if (GetBaseItemType(oLoot)==BASE_ITEM_SPELLSCROLL) { SetIdentified(oLoot,FALSE); } if (!GetIsObjectValid(oLoot)) { SendMessageToAllDMs("Error in monster loot script, item "+sString+" is invalid"); } } } } void TestCreatesRandomShield() { string sString=GetShield(); object oLoot=CreateItemOnObject(sString,OBJECT_SELF); int nBase=GetBaseItemType(oLoot); if (nBase==BASE_ITEM_SMALLSHIELD||nBase==BASE_ITEM_LARGESHIELD||nBase==BASE_ITEM_TOWERSHIELD) { oLoot=CreateRandomShield(oLoot); } }