Visit the Ironworks Gaming Website Email the Webmaster Graphics Library Rules and Regulations Help Support Ironworks Forum with a Donation to Keep us Online - We rely totally on Donations from members Donation goal Meter

Ironworks Gaming Radio

Ironworks Gaming Forum

Go Back   Ironworks Gaming Forum > Ironworks Gaming Forums > Neverwinter Nights 1 & 2 Also SoU & HotU Forum

Reply
 
Thread Tools Search this Thread
Old 08-17-2006, 08:44 AM   #1
robertthebard
Xanathar Thieves Guild
 

Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 60
Posts: 4,537
void main()
{
object oPC = GetFirstObjectInArea(OBJECT_SELF);
while ( GetIsObjectValid( oPC ) )
{
if (GetIsPC(oPC))
{
// Well, there you have it. Someone is still in the area. We don't want to
// clean up quite yet.

return;
}
if (GetObjectType( oPC )!=OBJECT_TYPE_CREATURE)
{
oPC = GetNextObjectInArea( OBJECT_SELF );
continue;

}

oPC = GetNextObjectInArea(OBJECT_SELF );
int iCount = 0;
object oObject = GetObjectByTag( "BodyBag", iCount );
while ( GetIsObjectValid( oObject ) )
{
// First, remove whatever treasure might be in it.
object oTreasure = GetFirstItemInInventory( oObject );
while ( GetIsObjectValid( oTreasure ) )
{
DestroyObject( oTreasure );
oTreasure = GetNextItemInInventory( oObject );
}
// Now, remove the body bag itself.
DestroyObject( oObject );
oObject = GetObjectByTag( "BodyBag", ++iCount );
}

}
}

This is supposed to check if there are any PC's in the area, and then destroy body bags. It compiles, and is on area exit, but doesn't destroy the body bags.
__________________
To those we have lost; May your spirits fly free.
Good Music: Here.
Interesting read, one of my blogs.
robertthebard is offline   Reply With Quote
Old 08-17-2006, 11:04 AM   #2
Legolas
Jack Burton
 

Join Date: March 31, 2001
Location: The zephyr lands beneath the brine.
Age: 39
Posts: 5,459
The script does the following:

1) Pick an object in the area. The entire script runs until there are no unchecked objects remaining.
2) If that object is a player, abort the script
3) If it's not a player and not a creature, pick another object
4) Pick yet another object instead even if you already did so (see 3)
5) Cycle through all 'bodybag' itens in the area
6) Cycle through all treasure in these bags
7) Destroy all treasure
8) Destroy all bags
9) Do it all over again for the currently selected object in the area

A couple of points:

Assume an area has 4 bodybags, 2 npcs and 1 player in it.
The first object might be the PC, but it could also be that you check 3 bags and 1 npc first meaning you delete part or all of the bags even with players in the area.

In addition, if you first select an npc, then a bag, then the PC, then another bag, your second check would mean that you find a creature so the next object is a bag. The bag is not a creature, so the next object is not the PC, but the bag that comes after it. Effectively you skip the PC in your object check.

After that, you never use the PC object again. In otehr words, all you want to use it for is to see if there's any PC in the area at all. There's no reason to place the second part inside this loop and you can put one of the last closing brackets between the
oPC = GetNextObjectInArea(OBJECT_SELF ); and int iCount = 0; parts instead.

You're likely better off replacing the first part with something like:
Quote:
object oPC = GetFirstPC();
while(GetIsObjectValid(oPC))
{
if(GetArea(oPC)==OBJECT_SELF)
{
return;
}
oPC = GetNextPC();
}
If you want you can also add a check to exclude DMs but that's optional.

As for the second part, the GetObjectByTag command doesn't just select body bags in the current area, but in all areas in your module. So if one area gets cleaned, so does another regardless of how many players are there.

Replace the second part with something like:
Quote:
object oBag = GetFirstObjectInArea(OBJECT_SELF);
while (GetIsObjectValid(oBag))
{
if(GetTag(oBag)=="BodyBag")
{
object oTreasure = GetFirstItemInInventory(oBag);
while (GetIsObjectValid(oTreasure))
{
DestroyObject(oTreasure);
oTreasure = GetNextItemInInventory(oBag);
}
DestroyObject(oBag);
}
oBag = GetnextObjectInArea(OBJECT_SELF);
}
Put parts 1 and 2 between a void main() { } and you should have something that works.
__________________


Say NO to the Trouser Tyranny!
Legolas is offline   Reply With Quote
Old 08-17-2006, 11:08 AM   #3
robertthebard
Xanathar Thieves Guild
 

Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 60
Posts: 4,537
Cool, off to try it out, thanks a bunch...
__________________
To those we have lost; May your spirits fly free.
Good Music: Here.
Interesting read, one of my blogs.
robertthebard is offline   Reply With Quote
Old 08-17-2006, 11:26 AM   #4
robertthebard
Xanathar Thieves Guild
 

Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 60
Posts: 4,537
Quote:
void main()
{
object oPC = GetFirstPC();
while(GetIsObjectValid(oPC))
{
if(GetArea(oPC)==OBJECT_SELF)
{
return;
}
oPC = GetNextPC();
}
object oBag = GetFirstObjectInArea(OBJECT_SELF);
while (GetIsObjectValid(oBag))
{
if(GetTag(oBag)=="BodyBag")
{
object oTreasure = GetFirstItemInInventory(oBag);
while (GetIsObjectValid(oTreasure))
{
DestroyObject(oTreasure);
oTreasure = GetNextItemInInventory(oBag);
}
DestroyObject(oBag);
}
oBag = GetnextObjectInArea(OBJECT_SELF);
}
}
Ok, this won't compile, I commented out the last oBag = line, and it compiled but I got: OID, Tag: ERROR: TOO MANY INSTRUCTIONS, message on area exit, and it didn't remove the body bag. I'm probably missing something really easy, but...

Should there be a true/false statement in either or both, aside from the object valid?

[ 08-17-2006, 11:27 AM: Message edited by: robertthebard ]
__________________
To those we have lost; May your spirits fly free.
Good Music: Here.
Interesting read, one of my blogs.
robertthebard is offline   Reply With Quote
Old 08-17-2006, 11:39 AM   #5
robertthebard
Xanathar Thieves Guild
 

Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 60
Posts: 4,537
Quote:
void main()
{
object oPC = GetFirstPC();
while(GetIsObjectValid(oPC))
{
if(GetArea(oPC)==OBJECT_SELF)
{
return;
}
oPC = GetNextPC();
}
object oBag = GetFirstObjectInArea(OBJECT_SELF);
while (GetIsObjectValid(oBag))
{
if(GetTag(oBag)=="BodyBag")
{
object oTreasure = GetFirstItemInInventory(oBag);
while (GetIsObjectValid(oTreasure))
{
DestroyObject(oTreasure);
oTreasure = GetNextItemInInventory(oBag);
}
DestroyObject(oBag);
}
//oBag = GetnextObjectInArea(OBJECT_SELF);
}
}
This variation cleaned the area, but still gave the too many instructions error.

Edit: Further testing results show that the cleaner part is only cleaning one bag out at a time, instead of all bags in the area.

[ 08-17-2006, 11:50 AM: Message edited by: robertthebard ]
__________________
To those we have lost; May your spirits fly free.
Good Music: Here.
Interesting read, one of my blogs.
robertthebard is offline   Reply With Quote
Old 08-17-2006, 11:55 AM   #6
Legolas
Jack Burton
 

Join Date: March 31, 2001
Location: The zephyr lands beneath the brine.
Age: 39
Posts: 5,459
I think I see the problem there. Instead of GetnextObjectInArea use GetNextObjectInArea. Commenting this part out is the reason it only cleans one at a time, and the small letter n means the command is not understood, resulting in compile errors.
The too many instructions sound like they're the result of a loop. And indeed, you'll get one if you don't cycle through the bags because you're always testing for the first one.
__________________


Say NO to the Trouser Tyranny!
Legolas is offline   Reply With Quote
Old 08-17-2006, 12:02 PM   #7
robertthebard
Xanathar Thieves Guild
 

Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 60
Posts: 4,537
LOL, knew it would be something easy...

Edit: Hooray, it works, thanks loads Legolas, 'preciate the help.

[ 08-17-2006, 12:06 PM: Message edited by: robertthebard ]
__________________
To those we have lost; May your spirits fly free.
Good Music: Here.
Interesting read, one of my blogs.
robertthebard is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Here's something for some scripters to chew over. robertthebard Neverwinter Nights 1 & 2 Also SoU & HotU Forum 9 03-06-2007 04:23 PM
another question for builders and scripters (mainly)... Mozenwrathe Neverwinter Nights 1 & 2 Also SoU & HotU Forum 0 02-01-2006 02:52 PM
question for builders and scripters... Mozenwrathe Neverwinter Nights 1 & 2 Also SoU & HotU Forum 0 02-01-2006 02:39 PM
Is it working right? Xen General Conversation Archives (11/2000 - 01/2005) 4 07-29-2003 05:11 AM
It's not working! Help!!!! Willard Neverwinter Nights 1 & 2 Also SoU & HotU Forum 2 10-05-2002 05:39 PM


All times are GMT -4. The time now is 01:24 AM.


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