PoA_PRC8/_module/nss/do_partyroll2.nss

118 lines
4.4 KiB
Plaintext
Raw Normal View History

2022-10-07 14:20:31 -04:00
//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 = "</c>";
const string COLOR_GREEN = "<c <20>d>"; //tells - acid
const string COLOR_RED = "<c<><<>";
const string COLOR_RED2 = "<c<>>"; //fire damage
const string COLOR_WHITE = "<c<><63><EFBFBD>>";
const string COLOR_BLUE = "<c!}<7D>>"; //electrical damage
const string COLOR_PURPLE = "<c<><EFBFBD>>"; //names
const string COLOR_LT_PURPLE = "<c<><EFBFBD>>";
const string COLOR_LT_GREEN = "<c<><63>d>";
const string COLOR_ORANGE = "<c<><63>2>";
const string COLOR_GOLD = "<c<><63>P>"; //shouts
const string COLOR_YELLOW = "<c<><63>>"; //send message to pc default (server messages)
const string COLOR_LT_BLUE = "<c<10><>>"; //dm channel
const string COLOR_LT_BLUE2 = "<c<><63><EFBFBD>>"; //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 = OBJECT_SELF;
DoPartyRoll(oPC);
}