Okay, it's not working yet because not not all control paths seem to return a value (in other words, the editor can think of values to enter which the script does not cover when it should) but I'm posting it anyway [img]smile.gif[/img]
This bit goes before the void main() section of a script and basically adds a new command to the set in the editor. It's a bit cluttered up by " else {return CLASS_TYPE_INVALID;}" lines because that was my first attempt at covering all the bases. They are not needed for the script itself to work, and the editor won't consider them to be covering everything.
Quote:
int GetHighestClassRandom(object oCreature);
int GetHighestClassRandom(object oCreature)
{
int iClass1 = GetClassByPosition(1, oCreature);
int iClass2 = GetClassByPosition(2, oCreature);
int iClass3 = GetClassByPosition(3, oCreature);
int iLevel1 = GetLevelByClass(iClass1, oCreature);
int iLevel2 = GetLevelByClass(iClass2, oCreature);
int iLevel3 = GetLevelByClass(iClass3, oCreature);
int iRandom2 = Random(2);
int iRandom3 = Random(3);
{
if((iClass2 != CLASS_TYPE_INVALID) && (iClass3 != CLASS_TYPE_INVALID))
{
if((iLevel1 == iLevel2) && (iLevel1 == iLevel3))
{
if(iRandom3 == 0)
{return iClass1;}
else if(iRandom3 == 1)
{return iClass2;}
else if(iRandom3 == 2)
{return iClass3;}
}
else if((iLevel1 == iLevel2) && (iLevel1 'smaller than' iLevel3))
{return iClass3;}
else if((iLevel1 == iLevel2) && (iLevel1 'greater than' iLevel3))
{
if(iRandom2 == 0)
{return iClass1;}
else if(iRandom2 == 1)
{return iClass2;}
}
else if((iLevel1 == iLevel3) && (iLevel1 'smaller than' iLevel2))
{return iClass2;}
else if((iLevel1 == iLevel3) && (iLevel1 'greater than' iLevel2))
{
if(iRandom2 == 0)
{return iClass1;}
else if(iRandom2 == 1)
{return iClass3;}
}
else if((iLevel2 == iLevel3) && (iLevel1 'smaller than' iLevel3))
{
if(iRandom2 == 0)
{return iClass2;}
else if(iRandom2 == 1)
{return iClass3;}
}
else if((iLevel2 == iLevel3) && (iLevel1 'greater than' iLevel3))
{return iClass1;}
else if((iLevel1 'greater than' iLevel2) && (iLevel1 'greater than' iLevel3))
{return iClass1;}
else if((iLevel2 'greater than' iLevel1) && (iLevel2 'greater than' iLevel3))
{return iClass2;}
else if((iLevel3 'greater than' iLevel2) && (iLevel3 'greater than' iLevel1))
{return iClass3;}
else {return CLASS_TYPE_INVALID;}
}
else if((iClass2 != CLASS_TYPE_INVALID) && (iClass3 == CLASS_TYPE_INVALID))
{
if(iLevel1 == iLevel2)
{
if(iRandom2 == 0)
{return iClass1;}
else if(iRandom2 == 1)
{return iClass2;}
}
else if (iLevel1 'smaller than' iLevel2)
{return iClass2;}
else if (iLevel1 'greater than' iLevel2)
{return iClass1;}
else {return CLASS_TYPE_INVALID;}
}
else if((iClass2 == CLASS_TYPE_INVALID) && (iClass3 == CLASS_TYPE_INVALID))
{return iClass1;}
else if((iClass2 == CLASS_TYPE_INVALID) && (iClass3 != CLASS_TYPE_INVALID))
{return CLASS_TYPE_INVALID;}
else {return CLASS_TYPE_INVALID;}
}
}
|
What it does (should do) is to return the highest class in the form of a CLASS_TYPE_*. You could use it later on in the container's script (after the void main()) for lines such as
Quote:
if(GetHighestClassRandom(OBJECT_SELF) == CLASS_TYPE_ARCANE_ARCHER)
{
CreateItemOnObject("archer item", OBJECT_SELF, 1);
}
|
Oh, right. The forum doesn't allow the 'greater than' and 'smaller than' symbols in the text.
[ 07-11-2003, 03:39 PM: Message edited by: Legolas ]