Ironworks Gaming Forum

Ironworks Gaming Forum (http://www.ironworksforum.com/forum/index.php)
-   Neverwinter Nights 1 & 2 Also SoU & HotU Forum (http://www.ironworksforum.com/forum/forumdisplay.php?f=16)
-   -   scripting a container to *drop* by class (http://www.ironworksforum.com/forum/showthread.php?t=35545)

robertthebard 07-10-2003 09:13 AM

I'm toolset stupid, how do i make a container get a char's class for treasure type to drop. I've seen it done, but can't figure out how, is there a script on the onopen, or ondeath that will give it, or do i need to write one? If so, can someone tell me how?

Legolas 07-10-2003 10:28 AM

It's a bit of a long script, but I wanted to include all the options and have you be able to give each and every one of them a different item. Just insert it somewhere in both the OnOpen script and the OnDeath scrip where it deals with handing out items.

Quote:

{
if(GetLevelByClass(CLASS_TYPE_ABERRATION, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_ANIMAL, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_ARCANE_ARCHER, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_ASSASSIN, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_BARBARIAN, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_BARD, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_BEAST, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_BLACKGUARD, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_CLERIC, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_COMMONER, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_CONSTRUCT, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_DRAGON, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_DRUID, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_ELEMENTAL, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_FEY, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_FIGHTER, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_GIANT, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_HARPER, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_HUMANOID, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_INVALID, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_MAGICAL_BEAST, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_MONK, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_MONSTROUS, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_OUTSIDER, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_PALADIN, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_RANGER, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_ROGUE, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_SHADOWDANCER, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_SHAPECHANGER, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_SORCERER, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_UNDEAD, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_VERMIN, GetLastOpenedBy()) > 0)
{
}
else if(GetLevelByClass(CLASS_TYPE_WIZARD, GetLastOpenedBy()) > 0)
{
}
}
You can cut some classes from this (I doubt you'll need the invalid class or the vermin class) by deleting the line dealing with the class and the two brackets that go with it.
You can add classes together by using the || or 'or' symbol, or create multiclass combinations using && or 'and'. For example, for a fighter/wizard and fighter/rogue only item you'd say

Quote:

else if(((GetLevelByClass(CLASS_TYPE_WIZARD, GetLastOpenedBy()) > 0) && (GetLevelByClass(CLASS_TYPE_FIGHTER, GetLastOpenedBy()) > 0)) || ((GetLevelByClass(CLASS_TYPE_ROGUE, GetLastOpenedBy()) > 0) && (GetLevelByClass(CLASS_TYPE_FIGHTER, GetLastOpenedBy()) > 0)))
{
}
The commands for the actual items etc. need to be added between the brackets { }, as I'm sure you'll know [img]smile.gif[/img]

What the "(GetLevelByClass(CLASS_TYPE_WIZARD, GetLastOpenedBy()) > 0)" line actually says is "does the character who last opened whatever calls this script have more than 0 levels in the wizard class?".

robertthebard 07-10-2003 02:01 PM

Thanks Legolas, that is a long script, and no, I didn't know. I'm finally getting around to trying to make a serious mod, instead of just an item stocker mod. Hence the toolset stupid thing. I feel good about myself if the doors and transitions work! :D Thanks again.

Legolas 07-10-2003 02:10 PM

Area transitions can be difficult to understand, you've every right to feel good if you figured that out by yourself [img]graemlins/thumbsup.gif[/img]
And you're welcome. If you need more help just post so [img]smile.gif[/img]

robertthebard 07-11-2003 08:40 AM

Ok, so will it award according to highest class, if a char is multi-class?

Legolas 07-11-2003 10:09 AM

This script won't, it only checks for at least a single level. Looking at it again, I think it also stops as soon as it has found a matching class. For example, a 19/1 fighter/aberration would only get the abberation items.
It shouldn't be much trouble to rewrite the script to go with the highest class, but if there are two tied for highest a choice still has to be made; do you give the items of one class, the other class, one of the classes at random, both the classes, nothing or a standard classless item?

I'm going to rewrite it to get the highest class level from the standard PC classes, and for now I'll make the item handed out in case of a tie one picked at random from between the two or three tied classes.

robertthebard 07-11-2003 03:06 PM

that would be a good idea, even if it just picked randomly between the two, so long as a monk's not getting druid items, etc. I've played a lot of cool stuff, and want to translate that over into this mod. Self closing doors, for example, and the reason behind this post. Just haven't gotten that good at it, yet...I've got a few areas drawn up, and a running story line, just got to work out the details.

Legolas 07-11-2003 03:36 PM

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 ]

Legolas 07-12-2003 11:37 AM

Meh, okay. I know the problem lies either in comparing the levels (might be), or in resolving the random outcomes (quite likely), or both (probably). It works for single class characters, when I remove the random bit it also works for characters with two classes, but for a character with three classes that doesn't seem to be enough.
I'm sure the fix is as easy as it is logical, I just have to spot it first [img]tongue.gif[/img] :D

robertthebard 07-12-2003 11:43 AM

thanks for all the hard work, really appreciate it, in the long run, it will be worth it. on the side, don't you have a module running, infinite realms, or something similar, if so, i've been a frequent visitor of late


All times are GMT -4. The time now is 06:40 PM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
©2024 Ironworks Gaming & ©2024 The Great Escape Studios TM - All Rights Reserved