Server Totals
Wilderness - (4)
Elysia - (1)
Ferrell - (0)
Le'Or - (0)
M'Chek - (0)
Deglos - (0)
Visimontium - (0)
Underdark - (0)
Mikona - (0)
Total players: 5
Gallery

Links Menu

Provisions Chest

Moderators: Nighthawk4, Dungeon Masters

Provisions Chest

PostAuthor: Hondo Hassan » Sat Jan 25, 2003 11:19 pm

I wrote these sets of scripts for a module I was working on. Players were in a village heading to "The City of the Dead" where there would be no merchants. So I created this system in which they have a chest on the docks that they put as much stuff as they want into it, and when it is shut it is "virtually" stored aboard a ship they will be taking to the new area. Once they take the ship there are 8 chests on the dock on the other side. The first chest they open has all the stuff the stored and a key. If they take the key then the chest is locked and no one can get to their stuff. If they leave the key in the chest then it does not lock and can be used by someone else. I just listed the scripts for the actually "provisions", but can post the "Locker" scripts if anyone is interested.

First script goes on the OnClose event on the First Chest:

void main()
{
object oPC=GetLastOpenedBy();
int ProvisionNumber=GetLocalInt(oPC,"ProvisionNumber");
object oItem=GetFirstItemInInventory(OBJECT_SELF);
while(GetIsObjectValid(oItem))
{
SetLocalString(oPC,"Provision"+IntToString(ProvisionNumber),GetTag(oItem));
SetLocalInt(oPC,"ProvisionQty"+IntToString(ProvisionNumber),GetNumStackedItems(oItem));
SetLocalInt(oPC,"ProvisionIdent"+IntToString(ProvisionNumber),GetIdentified(oItem));
ProvisionNumber++;
DestroyObject(oItem,0.0);
oItem=GetNextItemInInventory(OBJECT_SELF);
}
SetLocalInt(oPC,"ProvisionNumber",ProvisionNumber);
}

The next script goes on the OnOpen event of the chest in a new area (or Module I think):

void main()

{
object oPC=GetLastOpenedBy();
int ProvisionNumber=GetLocalInt(oPC,"ProvisionNumber");
if(ProvisionNumber!=0 && GetIsObjectValid(oPC))
{
int nX;

for(nX=0; nX<=(ProvisionNumber-1); nX++)
{
string sItemTemplate=GetLocalString(oPC,"Provision"+IntToString(nX));
int nStackSize=GetLocalInt(oPC,"ProvisionQty"+IntToString(nX));
object oItem=CreateItemOnObject(sItemTemplate, OBJECT_SELF, nStackSize);
SetIdentified(oItem, GetLocalInt(oPC,"ProvisionIdent"+IntToString(nX)) );
}
SetLocalInt(oPC,"ProvisionNumber",0);
}
}

Hondo Hassan
Newbie
 
Posts: 8
Joined: Thu Jan 16, 2003 1:42 am

PostAuthor: Hondo Hassan » Sat Jan 25, 2003 11:35 pm

It should be noted that in cases where the tag does not match the Blueprint ResRef, the item will be effectively destroyed, so it is recommended for just provisions not plot items. This is an old script so I am sure this shortcoming can be fixed by using the new GetResRef() command that was added in 1.25, but I have not had time to test that.

I simply have a conversation with the "Ferry attendant" that indicates that his employee's can be a little on the shady side and may steal any "unique" items placed in the chest (just like at major airports) so those are best left on their person.

Hondo Hassan
Newbie
 
Posts: 8
Joined: Thu Jan 16, 2003 1:42 am

PostAuthor: Orleron » Sun Jan 26, 2003 5:10 am

Thanks very much.
"Truth has no form."
--Idries Shah

World of Avlis Page

Avlis Project FAQ
User avatar
Orleron
World Advisor, Co-founder
World Advisor, Co-founder
 
Posts: 14933
Joined: Fri Sep 14, 2001 9:48 pm
Timezone: GMT-5


Return to NWN Scripting

Who is online

Registered users: Bing [Bot], Google [Bot]