Code: |
*/
//::////////////////////////////////////////////// //:: Created By: Andrew //:: Created On: //::////////////////////////////////////////////// void GenerateTreasure(int nTreasureType, object oLastOpener, object oCreateOn) { //dbSpeak("*********************NEW TREASURE*************************"); // * abort treasure if no one opened the container if (GetIsObjectValid(oLastOpener) == FALSE) { //dbSpeak("Aborted. No valid Last Opener"); return; } // * if no valid create on object, then create on oLastOpener if (oCreateOn == OBJECT_INVALID) { oCreateOn = oLastOpener; } // * if an Animal then generate 100% animal treasure // not done yet // * VARIABLES int nProbBook = 0; int nProbAnimal = 0; int nProbJunk = 0; int nProbGold = 0; int nProbGem = 0; int nProbJewel = 0; int nProbArcane = 0; int nProbDivine = 0; int nProbAmmo = 0; int nProbKit = 0; int nProbPotion = 0; int nProbTable2 = 0; int nSpecific = 0; int i = 0; int nNumberItems = GetNumberOfItems(nTreasureType); // * Set Treasure Type Values if (nTreasureType == TREASURE_LOW) { nProbBook = LOW_PROB_BOOK; nProbAnimal = LOW_PROB_ANIMAL; nProbJunk = LOW_PROB_JUNK; nProbGold = LOW_PROB_GOLD; nProbGem = LOW_PROB_GEM; nProbJewel = LOW_PROB_JEWEL; nProbArcane = LOW_PROB_ARCANE; nProbDivine = LOW_PROB_DIVINE; nProbAmmo = LOW_PROB_AMMO ; nProbKit = LOW_PROB_KIT; nProbPotion = LOW_PROB_POTION; nProbTable2 = LOW_PROB_TABLE2; } else if (nTreasureType == TREASURE_MEDIUM) { nProbBook = MEDIUM_PROB_BOOK; nProbAnimal = MEDIUM_PROB_ANIMAL; nProbJunk = MEDIUM_PROB_JUNK; nProbGold = MEDIUM_PROB_GOLD; nProbGem = MEDIUM_PROB_GEM; nProbJewel = MEDIUM_PROB_JEWEL; nProbArcane = MEDIUM_PROB_ARCANE; nProbDivine = MEDIUM_PROB_DIVINE; nProbAmmo = MEDIUM_PROB_AMMO ; nProbKit = MEDIUM_PROB_KIT; nProbPotion = MEDIUM_PROB_POTION; nProbTable2 = MEDIUM_PROB_TABLE2; } else if (nTreasureType == TREASURE_HIGH) { nProbBook = HIGH_PROB_BOOK; nProbAnimal = HIGH_PROB_ANIMAL; nProbJunk = HIGH_PROB_JUNK; nProbGold = HIGH_PROB_GOLD; nProbGem = HIGH_PROB_GEM; nProbJewel = HIGH_PROB_JEWEL; nProbArcane = HIGH_PROB_ARCANE; nProbDivine = HIGH_PROB_DIVINE; nProbAmmo = HIGH_PROB_AMMO ; nProbKit = HIGH_PROB_KIT; nProbPotion = HIGH_PROB_POTION; nProbTable2 = HIGH_PROB_TABLE2; } else if (nTreasureType == TREASURE_BOSS) { //dbSpeak("boss"); nProbTable2 = 100; nSpecific = 1; } else if (nTreasureType == TREASURE_BOOK) { nProbBook = 90; nProbArcane = 6; nProbDivine = 4; } //dbSpeak("Generate Treasure nSpecific = " + IntToString(nSpecific)); for (i = 1; i <= nNumberItems; i++) { int nRandom = d100(); if (nRandom <= nProbBook) CreateBook(oCreateOn); // * Book else if (nRandom <= nProbBook + nProbAnimal) CreateAnimalPart(oCreateOn); // * Animal else if (nRandom <= nProbBook + nProbAnimal + nProbJunk) CreateJunk(oCreateOn); // * Junk else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold) CreateGold(oCreateOn, oLastOpener, nTreasureType); // * Gold else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem) CreateGem(oCreateOn, oLastOpener, nTreasureType); // * Gem else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem + nProbJewel) CreateJewel(oCreateOn, oLastOpener, nTreasureType); // * Jewel else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem + nProbJewel + nProbArcane) CreateArcaneScroll(oCreateOn, oLastOpener); // * Arcane Scroll else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem + nProbJewel + nProbArcane + nProbDivine) CreateDivineScroll(oCreateOn, oLastOpener); // * Divine Scroll else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem + nProbJewel + nProbArcane + nProbDivine + nProbAmmo) CreateAmmo(oCreateOn, oLastOpener); // * Ammo else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem + nProbJewel + nProbArcane + nProbDivine + nProbAmmo + nProbKit) CreateKit(oCreateOn, oLastOpener); // * Healing, Trap, or Thief kit else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem + nProbJewel + nProbArcane + nProbDivine + nProbAmmo + nProbKit + nProbPotion) CreatePotion(oCreateOn, oLastOpener); // * Potion else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem + nProbJewel + nProbArcane + nProbDivine + nProbAmmo + nProbKit + nProbPotion + nProbTable2) { CreateTable2Item(oCreateOn, oLastOpener, nSpecific); // * Weapons, Armor, Misc - Class based } //else // dbSpeak("other stuff"); } } void GenerateLowTreasure(object oLastOpener, object oCreateOn=OBJECT_INVALID) { GenerateTreasure(TREASURE_LOW, oLastOpener, oCreateOn); } void GenerateMediumTreasure(object oLastOpener, object oCreateOn=OBJECT_INVALID) { GenerateTreasure(TREASURE_MEDIUM, oLastOpener, oCreateOn); } void GenerateHighTreasure(object oLastOpener, object oCreateOn=OBJECT_INVALID) { GenerateTreasure(TREASURE_HIGH, oLastOpener, oCreateOn); } void GenerateBossTreasure(object oLastOpener, object oCreateOn=OBJECT_INVALID) { GenerateTreasure(TREASURE_BOSS, oLastOpener, oCreateOn); } void GenerateBookTreasure(object oLastOpener, object oCreateOn=OBJECT_INVALID) { GenerateTreasure(TREASURE_BOOK, oLastOpener, oCreateOn); } //:://///////////////////////////////////////////// //:: GenerateNPCTreasure //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* Preferrably called from OnSpawn scripts. Use the random treasure functions to generate appropriate treasure for the creature to drop. */ //::////////////////////////////////////////////// //:: Created By: Brent //:: Created On: January 2002 //::////////////////////////////////////////////// void GenerateNPCTreasure(int nTreasureValue=1, object oTreasureGetter=OBJECT_SELF, object oKiller=OBJECT_SELF) { //DestroyObject(OBJECT_SELF); // * if I am an animal ,then give me animal stuff instead if (GetObjectType(oTreasureGetter) == OBJECT_TYPE_CREATURE) { if ( (GetRacialType(oTreasureGetter) == RACIAL_TYPE_UNDEAD) || (GetRacialType(oTreasureGetter) == RACIAL_TYPE_ANIMAL) || (GetRacialType(oTreasureGetter) == RACIAL_TYPE_BEAST) || (GetRacialType(oTreasureGetter) == RACIAL_TYPE_MAGICAL_BEAST) || (GetRacialType(oTreasureGetter) == RACIAL_TYPE_VERMIN) ) { //CreateAnimalPart(oTreasureGetter); // April 23 2002: Removed animal parts. They are silly. return; } } if (nTreasureValue == 1) { // April 2002: 30% chance of not getting any treasure now // if a creature if (Random(100)+1 <= LOW_TREASURE_DROP_CHANCE) { GenerateTreasure(TREASURE_LOW, oTreasureGetter, oKiller); } } else if (nTreasureValue == 2) { if (Random(100)+1 <= MID_TREASURE_DROP_CHANCE) { GenerateTreasure(TREASURE_MEDIUM, oTreasureGetter, oKiller); } } else if (nTreasureValue == 3) { if (Random(100)+1 <= HIGH_TREASURE_DROP_CHANCE) { GenerateTreasure(TREASURE_HIGH, oTreasureGetter, oKiller); } } else if (nTreasureValue == 4) { GenerateBossTreasure(oKiller, oTreasureGetter); } } // * // * Theft Prevention // * //:://///////////////////////////////////////////// //:: ShoutDisturbed //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* */ //::////////////////////////////////////////////// //:: Created By: //:: Created On: //::////////////////////////////////////////////// // * Container shouts if disturbed void ShoutDisturbed() { if (GetIsDead(OBJECT_SELF) == TRUE) { object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, GetLocation(OBJECT_SELF), TRUE, OBJECT_TYPE_CREATURE); //Cycle through the targets within the spell shape until an invalid object is captured. while (GetIsObjectValid(oTarget)) { if (GetFactionEqual(oTarget, OBJECT_SELF) == TRUE) { // * Make anyone who is a member of my faction hostile if I am violated object oAttacker = GetLastAttacker(); SetIsTemporaryEnemy(oAttacker,oTarget); AssignCommand(oTarget, ActionAttack(oAttacker)); } oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, GetLocation(OBJECT_SELF), TRUE, OBJECT_TYPE_CREATURE); } } else if (GetIsOpen(OBJECT_SELF) == TRUE) { object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, GetLocation(OBJECT_SELF), TRUE, OBJECT_TYPE_CREATURE); //Cycle through the targets within the spell shape until an invalid object is captured. while (GetIsObjectValid(oTarget)) { if (GetFactionEqual(oTarget, OBJECT_SELF) == TRUE) { // * Make anyone who is a member of my faction hostile if I am violated object oAttacker = GetLastOpener(); SetIsTemporaryEnemy(oAttacker,oTarget); AssignCommand(oTarget, ActionAttack(oAttacker)); } oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, GetLocation(OBJECT_SELF), TRUE, OBJECT_TYPE_CREATURE); } } } //:://///////////////////////////////////////////// //:: Determine Class to Use //:: Copyright (c) 2002 Bioware Corp. //::////////////////////////////////////////////// /* Determines which of a NPCs three classes to use in the random treasure system */ //::////////////////////////////////////////////// //:: Created By: Preston Watamaniuk //:: Created On: April 4, 2002 //::////////////////////////////////////////////// int nDetermineClassToUse(object oCharacter) { int nClass; int nTotal = GetHitDice(oCharacter); //dbSpeak("Hit dice " + IntToString(nTotal)); if (nTotal < 1) { nTotal = 1; } /* float fTotal = IntToFloat(nTotal); //if (GetIsObjectValid(oCharacter) == FALSE) //{ // dbSpeak("DetermineClassToUse: This character is invalid"); //} int nClass1 = GetClassByPosition(1, oCharacter); int nState1 = FloatToInt((IntToFloat(GetLevelByClass(nClass1, oCharacter)) / fTotal) * 100); //dbSpeak("Level 1 Class Level = " + IntToString(GetLevelByClass(nClass1,oCharacter))); //PrintString("GENERIC SCRIPT DEBUG STRING ********** " + GetTag(oCharacter) + "Class 1 " + IntToString(nState1)); //dbSpeak("State 1 " + IntToString(nState1)); int nClass2 = GetClassByPosition(2, oCharacter); int nState2 = FloatToInt((IntToFloat(GetLevelByClass(nClass2, oCharacter)) / fTotal) * 100) + nState1; //PrintString("GENERIC SCRIPT DEBUG STRING ********** " + GetTag(oCharacter) + "Class 2 " + IntToString(nState2)); int nClass3 = GetClassByPosition(3, oCharacter); int nState3 = FloatToInt((IntToFloat(GetLevelByClass(nClass3, oCharacter)) / fTotal) * 100) + nState2; //PrintString("GENERIC SCRIPT DEBUG STRING ********** " + GetTag(oCharacter) + "Class 3 " + IntToString(nState3)); */ int nClass1 = GetClassByPosition(1, oCharacter); int nClass2 = GetClassByPosition(2, oCharacter); int nClass3 = GetClassByPosition(3, oCharacter); int nState1 = GetLevelByClass(nClass1, oCharacter) * 100 / nTotal; int nState2 = GetLevelByClass(nClass2, oCharacter) * 100 / nTotal + nState1; // nState3 will always be 100 if there is a third class, or 0 if there isn't //int nState3 = GetLevelByClass(nClass3, oCharacter) * 100 / nTotal + nState2; // correct for unrecognized classes - assumes the first class will be a non-prestige player class if(nClass2 != CLASS_TYPE_INVALID && nClass2 > CLASS_TYPE_WIZARD) { nClass2 = CLASS_TYPE_INVALID; nState1 = nState2; } if(nClass3 != CLASS_TYPE_INVALID && nClass3 > CLASS_TYPE_WIZARD) { nClass3 = CLASS_TYPE_INVALID; if(nClass2 != CLASS_TYPE_INVALID) nState2 = 100; else nState1 = 100; } int nUseClass = d100(); //PrintString("GENERIC SCRIPT DEBUG STRING ********** " + "D100 Roll " +IntToString(nUseClass)); //dbSpeak("Before comparison : " + IntToString(nClass1)); if(nUseClass <= nState1) { nClass = nClass1; } else if(nUseClass > nState1 && nUseClass <= nState2) { nClass = nClass2; } else { // might be possible to end up here by accident because of a rounding error // so just in case... if(nClass3 == CLASS_TYPE_INVALID) nClass = nClass1; else nClass = nClass3; } //dbSpeak("Class from determineClass " + IntToString(nClass)); return nClass; } |