Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Categories

Dark Dreams of Furiae - a new module for NWN:EE! Buy now
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

Learning to script: How to get pc's area

Hey guys I've been slowly learning how to use the nw script. So far the pattern has been

1.) Learn something new
2.) write some scripts
3.) Run up against a wall
4.) Rage quit
5.) Come back later bright eyed and optimistic
6.) Repeat

Hoping you guys can help me skip the rage quit this time. Right now I created an item with a use unique power property. In the on activated item script I roll a 1d100 and they receive an item depending on the roll. I plan on having the results of the d100 be different depending on the area that they're in (the game will be crafting heavy and they're searching the natural environment for things).

Below you'll find my attempt at that. I think the error lies in the if statement
if ((GetTag(oItem) == "it_Search") && (GetTag(oArea001) == GetTag(oUserArea)))

but I could be totally wrong about that. The attempted code on the right of the && symbol is trying to get the area of a placeable and the area of a player then check to see if they are the same using the == Please lemmee know what horrible mistake(s) I'm making. Thanks in advance and sorry for the inconvenience.





//Search Tool

//The Item that was activated
object oItem = GetItemActivated();
//The person that used the item
object oUser = GetItemActivator();
//Rocks in area001 and use that object to get the area the rocks are in (Area001)
object oRocks001 = GetObjectByTag("pl_Area001",1);
object oArea001 = GetArea(oRocks001);

//
object oUserArea = GetArea(oUser);

//If the object being used is the Search Tool then execute the following script
if ((GetTag(oItem) == "it_Search") && (GetTag(oArea001) == GetTag(oUserArea)))
{

//The loot tree for Area001
int nSearchSkill = GetSkillRank(SKILL_SEARCH, oUser, FALSE);
int nItemFound = 1;
int nRandomItem = d100(1);

if(GetIsSkillSuccessful(oUser, SKILL_SEARCH, 12))
{
if(nRandomItem <= 30)
{
CreateItemOnObject("it_TreeBranch", oUser, nItemFound);
}
else if((nRandomItem > 30) && (nRandomItem <= 50))
{
CreateItemOnObject("it_Log", oUser, nItemFound);
}
else if((nRandomItem > 50) && (nRandomItem <= 55))
{
CreateItemOnObject("it_BirdEgg", oUser, nItemFound);
}
else if((nRandomItem > 55) && (nRandomItem <= 60))
{
CreateItemOnObject("it_Mushroom", oUser, nItemFound);
}
else if((nRandomItem > 60) && (nRandomItem <= 70))
{
CreateItemOnObject("it_Acorn", oUser, nItemFound);
}
else if((nRandomItem > 70) && (nRandomItem <= 80))
{
CreateItemOnObject("it_Insect", oUser, nItemFound);
}
else if((nRandomItem > 80) && (nRandomItem <= 90))
{
CreateItemOnObject("it_Flint", oUser, nItemFound);
}
else if((nRandomItem > 90) && (nRandomItem <= 95))
{
CreateItemOnObject("it_GraniteRock", oUser, nItemFound);
}
else if((nRandomItem > 95) && (nRandomItem <= 100))
{
CreateItemOnObject("it_SmallBone", oUser, nItemFound);
}
}
}

Comments

Sign In or Register to comment.