08-17-2006, 08:44 AM | #1 |
Xanathar Thieves Guild
Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 61
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. |
08-17-2006, 11:04 AM | #2 | ||
Jack Burton
Join Date: March 31, 2001
Location: The zephyr lands beneath the brine.
Age: 40
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:
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:
|
||
08-17-2006, 11:08 AM | #3 |
Xanathar Thieves Guild
Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 61
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. |
08-17-2006, 11:26 AM | #4 | |
Xanathar Thieves Guild
Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 61
Posts: 4,537
|
Quote:
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. |
|
08-17-2006, 11:39 AM | #5 | |
Xanathar Thieves Guild
Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 61
Posts: 4,537
|
Quote:
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. |
|
08-17-2006, 11:55 AM | #6 |
Jack Burton
Join Date: March 31, 2001
Location: The zephyr lands beneath the brine.
Age: 40
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. |
08-17-2006, 12:02 PM | #7 |
Xanathar Thieves Guild
Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 61
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. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
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 |