PoA_PRC8/module/nss/setmulticolor.nss

105 lines
3.0 KiB
Plaintext
Raw Normal View History

2022-10-07 14:20:31 -04:00
//Script Name: setrandomcolor
//////////////////////////////////////////
//Created by: Genisys / Guile
//ON: 6/17/08
/////////////////////////////////////////
/* **Notes**
This script goes in the Action Taken
of a Converstion Line ONLY! It will
colorize ALL Of the items in a PCs
inventory a random color, each item a
different color!
*/
////////////////////////////////////////
//WARNING: DON'T TOUCH THE STRINGS BELOW!!!!!!////
const string COLORTOKEN = " ##################$%&'()*+,-./0123456789:;;==?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[[]^_`abcdefghijklmnopqrstuvwxyz{|}~~<7E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
// returns a properly color-coded string based on specified RGB values
string ColorString(int nRed=255, int nGreen=255, int nBlue=255)
{
return "<c" + GetSubString(COLORTOKEN, nRed, 1) + GetSubString(COLORTOKEN, nGreen, 1) + GetSubString(COLORTOKEN, nBlue, 1) + ">";
}
//Main Script//
void main()
{
//Define Major Variables
object oPC = GetPCSpeaker() ;
object oItem;
string sColor;
int a;
int b;
int c;
oItem = GetFirstItemInInventory(oPC);
//Loop through all the items in the PC's inventory..
while(GetIsObjectValid(oItem)==TRUE)
{
//Be careful with items with a color string already on them!!!
if(GetSubString(GetName(oItem), 0, 2)=="<c")
{
a = Random(255); b = Random(255); c = Random(255);
//This color value will change EVERY time an item is selected.
sColor = ColorString(a,b,c);
//Get the actual name of the item minus the color code..
string sName = GetSubString(GetName(oItem), 6, 40);
//Set the color to the item's name
SetName(oItem, sColor + sName);
}
//Since there is no color tag on the item's name give it one..
else
{
a = Random(255); b = Random(255); c = Random(255);
//This color value will change EVERY time an item is selected.
sColor = ColorString(a,b,c);
//Set the random color to the item's name..
SetName(oItem, sColor + GetName(oItem));
}
//Get all of the items!
oItem = GetNextItemInInventory(oPC);
}
//Next cycle through all items equipped by the PC///
int nSlot;
for (nSlot=0; nSlot<NUM_INVENTORY_SLOTS; nSlot++)
{
oItem=GetItemInSlot(nSlot, oPC);
//Be careful with items with a color string already on them!!!
if(GetSubString(GetName(oItem), 0, 2)=="<c")
{
a = Random(255); b = Random(255); c = Random(255);
//This color value will change EVERY time an item is selected.
sColor = ColorString(a,b,c);
//Get the actual name of the item minus the color code..
string sName2 = GetSubString(GetName(oItem), 6, 40);
//Set the color to the item's name
SetName(oItem, sColor + sName2);
}
//Since there is no color tag on the item's name give it one..
else
{
a = Random(255); b = Random(255); c = Random(255);
//This color value will change EVERY time an item is selected.
sColor = ColorString(a,b,c);
//Set the random color to the item's name..
SetName(oItem, sColor + GetName(oItem));
}
//end loop
}
//End Script
}