//Script Name: do_partyroll ////////////////////////////////////////// //Created By: Genisys (Guile) //Created On: 8/25/08 ///////////////////////////////////////// /* ALL Of the functions within were taken from the DMFI Project By FunkySwerve's fky_chat includes, awesome stuff! */ //::////////////////////////////////////////////////////////////////////////::// //:: Functions from Higher Ground's fky_chat/ dmfi Project //:: Designed By: FunkySwerve ::// //:: Designed On: April 4 2006 ///////////////////////////////////////////////////////////////////////// const string ESCAPE_STRING = "&&"; const string COLOR_END = ""; const string COLOR_GREEN = ""; //tells - acid const string COLOR_RED = ""; const string COLOR_RED2 = ""; //fire damage const string COLOR_WHITE = ""; const string COLOR_BLUE = ""; //electrical damage const string COLOR_PURPLE = ""; //names const string COLOR_LT_PURPLE = ""; const string COLOR_LT_GREEN = ""; const string COLOR_ORANGE = ""; const string COLOR_GOLD = ""; //shouts const string COLOR_YELLOW = ""; //send message to pc default (server messages) const string COLOR_LT_BLUE = ""; //dm channel const string COLOR_LT_BLUE2 = ""; //cold damage const string NEWLINE = "\n"; const string ROLL1 = " rolled a ["; const string ROLL2 = "] and got a: ["; const string ROLLGOOD = "Wow! Nice roll!"; int GetHighestItemFromArray(object oPC, int nNumberInArray) { string sString, sInt, sAdd; int nInt, nNum; int nHighest = -1; int nArrayNum = 0; for (nInt = 1; nInt <= nNumberInArray; nInt++) { sInt = IntToString(nInt); sString = GetLocalString(oPC, "PRMember"+sInt); if (sString != "") { nNum = StringToInt(GetStringLeft(sString, 2)); if (nNum > nHighest) { nHighest = nNum; nArrayNum = nInt; } } } return nArrayNum; } void DoPartyRoll(object oPlayer) { object oLeader = GetFactionLeader(oPlayer); object oPartymember; int nRoll, nInt, nNumberItemsInArray, nNumBase, nTopRoller; int nCount = 0; string sInt, sBase, sNumBase, sLine, sRoll, sName; string sMessage = ""; if (oPlayer == oLeader)//only leader can roll { oPartymember = GetFirstFactionMember(oPlayer); //oPartymember = GetFirstItemInInventory(oPlayer); while (GetIsObjectValid(oPartymember))//generate the 'array' { nCount++;//get number in party nRoll = Random(100); sRoll = IntToString(nRoll); if (GetStringLength(sRoll) == 1) sRoll = "0" + sRoll;//ensure that string length is consistent sInt = IntToString(nCount); SetLocalString(oPlayer, "PRMember"+sInt, sRoll+GetName(oPartymember)); oPartymember = GetNextFactionMember(oPlayer); //oPartymember = GetNextItemInInventory(oPlayer); } nNumberItemsInArray = nCount; for (nInt = 1; nInt <= nCount; nInt++) //once through for each member of the party { //find the highest number nTopRoller = GetHighestItemFromArray(oPlayer, nNumberItemsInArray); //add it to the string along with their name sBase = GetLocalString(oPlayer, "PRMember"+IntToString(nTopRoller)); nNumBase = StringToInt(GetStringLeft(sBase, 2)); nNumBase++;//add 1 to simulate 1 to 100 roll instead of 0 to 99 sNumBase = IntToString(nNumBase); sName = GetStringRight(sBase, (GetStringLength(sBase) - 2)); //sLine = sName + " rolled a " + sNumBase + ".\n"; sLine = COLOR_WHITE+sName+ROLL1+COLOR_END+COLOR_GREEN+"D100"+COLOR_END+COLOR_WHITE+ROLL2+COLOR_END+COLOR_GOLD+sNumBase+COLOR_END+COLOR_WHITE+"].\n"; sMessage += sLine; //delete that array entry, no need to pack it DeleteLocalString(oPlayer, "PRMember"+IntToString(nTopRoller)); } //Send the final message to the party AssignCommand(oPlayer, SpeakString(COLOR_GOLD + "Party Roll: "+ COLOR_END + sMessage)); oPartymember = GetFirstFactionMember(oPlayer); while (GetIsObjectValid(oPartymember)) { SendMessageToPC(oPartymember, sMessage); oPartymember = GetNextFactionMember(oPlayer); } } } void main() { object oPC = GetPCSpeaker(); DoPartyRoll(oPC); }