DysoForums Forum Index DysoForums
 
GalleryGallery   Donate to DysotopiaDonate   Dysotopia.com homepageDyso.com
SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStats   RegisterRegister 
 Login to check your private messagesLogin to check your private messages   LoginLogin 

Persistent Chest

 
Post new topic   Reply to topic    DysoForums Forum Index -> Worldbuilders
View previous topic :: View next topic :: Hide signatures  
Author Message
Ectovult
Elder


Joined: 18 Sep 2002
Posts: 755

Level: 24
XP
EXP: 57 / 68 EXP: 57 / 68 EXP: 57 / 68
 83%
PostPosted: Tue Jul 29, 2003 12:53 pm    Post subject: Persistent Chest Reply with quote

w00t!!!
I've just finished my very own home made persistent chest, using nwn's new database functions... icon_biggrin.gif
_________________
"Nothing that is beautiful in life is taken away with death"
Back to top
View users profile Send private message Send email
Little Teapot
PostTue 07/29/03 5:00pm
please tell me you didn't use OnClose for that... (other than Item Deletion)  Reply with quote
 
guitarrML
PostTue 07/29/03 5:09pm
I was just wondering how to do that?! Mind sharing it?  Reply with quote
 
Ectovult
Elder


Joined: 18 Sep 2002
Posts: 755

Level: 24
XP
EXP: 57 / 68 EXP: 57 / 68 EXP: 57 / 68
 83%
PostPosted: Tue Jul 29, 2003 8:55 pm    Post subject: Reply with quote

I tried OnClose, but it made it too damn slow...
I'm working in another system now, I'm also working in a bounty system. It's getting pretty cool icon_wink.gif
_________________
"Nothing that is beautiful in life is taken away with death"
Back to top
View users profile Send private message Send email
Darkshadow666
Grandmaster


Joined: 31 Jan 2003
Posts: 297

Level: 16
XP
EXP: 5 / 39 EXP: 5 / 39 EXP: 5 / 39
 12%
PostPosted: Wed Jul 30, 2003 1:19 pm    Post subject: Reply with quote

anybody believe in Freeware??? If so, are you willing to share the code for a persistant chest? I'm not an accomplished scripter and that's way over my head. icon_mad.gif
_________________
Co-Creator of DragonsFall Mod
Back to top
View users profile Send private message Send email Visit posters website
Little Teapot
Deity


Joined: 11 Sep 2002
Posts: 2332

Level: 39
XP
EXP: 31 / 160 EXP: 31 / 160 EXP: 31 / 160
 19%
PostPosted: Wed Jul 30, 2003 5:43 pm    Post subject: Reply with quote

these stand a fair chance of working... I ripped them outta my personal chest
on disturbed of the chest:
Code:
//::///////////////////////////////////////////////
//:: Name OnDisturbed, Persistent Chest
//:: FileName pc_ondisturbed.nss
//:://////////////////////////////////////////////
/*
    Keeps track of Database and Items in the
    chest for use in a persistent chest. keeps
    track of each individual chest's inventory
    by it's location.
*/
//:://////////////////////////////////////////////
//:: Created By: Greg Baker
//:: Created On: 7/30/2003
//:://////////////////////////////////////////////

string LocationToString(location lLocation);

void main()
{

    string sLocation=LocationToString(GetLocation(OBJECT_SELF));
    object oItem = GetInventoryDisturbItem();
    int nType = GetInventoryDisturbType();
    int nNum = GetCampaignInt(GetTag(GetModule()), "pc_itemnum"+sLocation);
    string sItem;
    string working;

    if(nType==INVENTORY_DISTURB_TYPE_ADDED)
    {
        SetLocalString(oItem, "pc_item", "pc_item"+IntToString(nNum));
        StoreCampaignObject(GetTag(GetModule()), "pc_item"+IntToString(nNum)+sLocation, oItem);
        SetCampaignInt(GetTag(GetModule()), "pc_itemnum"+sLocation, (nNum+1));
        return;
    }
    else
    {
        nNum--;
        sItem = GetLocalString(oItem, "pc_item");
        if(sItem != "")
        {
            working = "pc_item"+IntToString(nNum);
            DeleteLocalString(oItem, "pc_item");
            oItem=GetFirstItemInInventory();
            while(GetLocalString(oItem, "pc_item")!=working
            && GetIsObjectValid(oItem))
            {
                oItem=GetNextItemInInventory();
            }
            SetLocalString(oItem, "pc_item", sItem);
            SetCampaignInt(GetTag(GetModule()), "pc_itemnum"+sLocation, nNum);
            StoreCampaignObject(GetTag(GetModule()), sItem+sLocation, oItem);
            return;
        }
        else
            WriteTimestampedLogEntry("Persistent Chest has lost an Item missing pc_item local variable");
    }
}

string LocationToString(location lLocation)
{
    string sReturn=GetTag(GetAreaFromLocation(lLocation));
    vector vVect=GetPositionFromLocation(lLocation);


    sReturn+=FloatToString(vVect.x, 0, 2)+",";
    sReturn+=FloatToString(vVect.y, 0, 2)+",";
    sReturn+=FloatToString(vVect.z, 0, 2)+",";
    sReturn+=FloatToString(GetFacingFromLocation(lLocation), 0, 2);
    return sReturn;
}


on open:

Code:
//::///////////////////////////////////////////////
//:: Name Persistent Chest OnOpen
//:: FileName pc_onopen.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Fills chest with items stored in the db. Marks
    each with a local variable with their DB index
*/
//:://////////////////////////////////////////////
//:: Created By: Greg Baker
//:: Created On: 7/30/03
//:://////////////////////////////////////////////

string LocationToString(location lLocation);
void main()
{

    string sLocation=LocationToString(GetLocation(OBJECT_SELF));
    object test=GetFirstItemInInventory(OBJECT_SELF);
    while(GetIsObjectValid(test))
    {
        DeleteLocalString(test, "pc_item");
        DestroyObject(test);
        test=GetNextItemInInventory();
    }



    int increment = GetCampaignInt(GetTag(GetModule()), "pc_itemnum"+sLocation);
    int i=0;
    for(i=0; i<increment; i++)
    {
        test = RetrieveCampaignObject(GetTag(GetModule()), "pc_item"+IntToString(i)+sLocation, GetLocation(OBJECT_SELF), OBJECT_SELF);
        SetLocalString(test, "pc_item", "pc_item"+IntToString(i));
    }

}

string LocationToString(location lLocation)
{
    string sReturn=GetTag(GetAreaFromLocation(lLocation));
    vector vVect=GetPositionFromLocation(lLocation);


    sReturn+=FloatToString(vVect.x, 0, 2)+",";
    sReturn+=FloatToString(vVect.y, 0, 2)+",";
    sReturn+=FloatToString(vVect.z, 0, 2)+",";
    sReturn+=FloatToString(GetFacingFromLocation(lLocation), 0, 2);
    return sReturn;
}


in theory these should work... they're untested though, so I'm not quite sure.
_________________
Matthijs says:
   oh ja, ik weet het zonet nog niet
Matthijs says:
   het ziet er toch wel een beetje naar uit dat we nederlands praten
Matthijs says:
   mischien moet ik dan maar eens vaker nederlands gaan praten
Matthijs says:
   kan je me ook meteen niet op al mijn spellinsfouten wijzen
There you have it! indisputable proof Solo's a fascist!!!


Last edited by Little Teapot on Wed Jul 30, 2003 10:00 pm, edited 3 times in total
Back to top
View users profile Send private message Send email AIM Address MSN Messenger
Ectovult
Elder


Joined: 18 Sep 2002
Posts: 755

Level: 24
XP
EXP: 57 / 68 EXP: 57 / 68 EXP: 57 / 68
 83%
PostPosted: Wed Jul 30, 2003 8:26 pm    Post subject: Reply with quote

My system with OnClose works just fine.. The problem is, it gets pretty slow when you close the chest. I'm afraid it would cause an awfull lot of lag in any server.
I'm working on a new system with OnDisturb. It should be ready tonight.

I'll post it here once I test it.
_________________
"Nothing that is beautiful in life is taken away with death"
Back to top
View users profile Send private message Send email
Display posts from previous:   
Post new topic   Reply to topic    DysoForums Forum Index -> Worldbuilders All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.2 © 2001, 2002 phpBB Group