Author Topic: Bury gold and retreiving it  (Read 1495 times)

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #15 on: October 12, 2010, 01:47:42 am »


               Or, upon that chest being closed it could start a conversation that ask if that is all the pc wants to store in the chest and if so it is then buried.
               
               

               
            

Legacy_tmanfoo

  • Full Member
  • ***
  • Posts: 129
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #16 on: October 12, 2010, 10:13:45 am »


               I really like this idea, and have added it to my list of things to explore further eventually.  You could use a paint-able trigger to define the dig zones in any given area.  



I know there have been ‘buried treasure’ systems out there in the past, as well as persistent object storage, a simple merge of the two would provide the desired result.  Opening a container after the dig would be IMO the desired result, regardless of put or get.



I know Higher Ground uses a persistent storage system for items.  I don’t know however if they are using it via resref, or if the item appearance, properties, name, etc. are stored instead.  Whatever the case, perhaps they will share this info if someone asks nicely.  

               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #17 on: October 12, 2010, 05:14:50 pm »


               Just a thought not written in stone

SHOVEL SCRIPT--------------------------------------------------------------------------------------------------------------------------
Pc uses shovel and  plays animation get low delaying 5 seconds.
When playing the annimation the shovelscript checks to see if the charater is in a AREA that has a invisable obeject in it because we dont want pcs digging on 2nd story buildings.

If the invisable object is found in the AREA spawn in a small hole placeable in front of the pc also open the inventory of chest and start  a conversation.


CONVERSATION NODES-------------------------------------------------------------------------------------------------------------
On_open does nothing or needs ideas
On_close should create a map of the treasue storeing its location
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #18 on: October 12, 2010, 09:12:36 pm »


               This shovel script should work better. I will message you my email addy you can build the convo then email it to me and I will work up the rest of the system. I will also need a resref for a critter to store the items on, and an area tag to spawn the creature into other than the area the pc will be in, no need for them pc to see the critter.

#include "x2_inc_switches"
#include "x0_i0_position"

const string MAP_OBJECT   = "map_resref_here";
const string INVIS_OBJECT = "invisible_object_tag_here";
const string CHEST_OBJECT = "chest_resref_here";
const string CHEST_TAG    = "chest_tag_here";
const string HOLE_OBJECT  = "hole_resref_here";
const string CONVO_RES    = "conversation_resref_here";

const string NEAR = "This map leads to a buried treasure, near ";
const string AREA = "In the area know as ";

void CreateHole(location lP1)
{
 CreateObject(OBJECT_TYPE_PLACEABLE, HOLE_OBJECT, lP1);
}

void CreateChest(location lP2)
{
 CreateObject(OBJECT_TYPE_PLACEABLE, CHEST_OBJECT, lP2);
}

void StartConvo(string ConvoRes, object oPC)
{
 object oChest = GetNearestObjectByTag(CHEST_TAG, oPC);
 ActionStartConversation(oChest, CONVO_RES, TRUE, FALSE);
}

void main()
{
 if(GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE) return;

 object oPC = GetItemActivator();

 if(GetNearestObjectByTag(INVIS_OBJECT) == OBJECT_INVALID)
 {
  SendMessageToPC(oPC, "You may not bury items in this area.");
  return;
 }

 location lP1 = GetAheadLocation(oPC);
 location lP2 = GetAheadRightLocation(oPC);
 object oChest;

 AssignCommand(oPC, PlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 5.0));
 DelayCommand(5.0, CreateHole(lP1));
 DelayCommand(5.1, CreateChest(lP2));
 DelayCommand(5.2, StartConvo(CONVO_RES, oPC));

}

               
               

               


                     Modifié par Baragg, 12 octobre 2010 - 08:13 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #19 on: October 12, 2010, 09:14:20 pm »


               Oh, I use a vanilla nwn module to do most scripting in so I did not find a hole that is why I put the const string for it there you can fill that in.
               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #20 on: October 13, 2010, 01:19:57 am »


               CONVERSATION NODES


-   ------>Root
          +You have maaged to dig a hole
               -Bury Treasure
               -Leave
             

RESREF/TAGS


Resref of creature to hold items                             nw_ac_pant01
Tag of area to spawn in                                           GS_AREA_INVENTORY
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #21 on: October 13, 2010, 02:46:42 pm »


               This would go on the "leave" node of the convo. Also I would clarify on the bury treasure node that upon closing the chest the chest will be buried, so don't close it till your done. Oh, and we will need a waypoint to spawn at in that area, sorry for asking for the area tag.


const string HOLE_OBJECT  = "hole_resref_here";
const string CHEST_OBJECT = "chest_resref_here";

void main()
{
 object oPC = GetPCSpeaker();
 object oHole = GetNearestObjectByTag(HOLE_OBJECT, oPC);
 object oChest = GetNearestObjectByTag(CHEST_OBJECT, oPC);

 DestroyObject(oHole);
 DestroyObject(oChest);
}


This would be the chest onclose script


const string CRITTER  = "nw_ac_pant01";
const string WAYPOINT = "tag_of_waypoint_to_spawn_at";
const string MAP      = "map_resref_here";
const string LEADS    = "This map leads to a treasure, in the area known as ";
const string NEAR     = "The treasure is near ";
const string HOLE     = "hole_tag_here";

void main()
{
 location lP1 = GetLocation(GetWaypointByTag(WAYPOINT));
 object oChest = OBJECT_SELF;
 object oItem = GetFirstItemInInventory(oChest);
 object oPC = GetLastUsedBy();
 string sName = GetName(oPC);
 int nCamp = GetCampaignInt("TREASURE_CHEST", sName, oPC);
 object oCritter = CreateObject(OBJECT_TYPE_CREATURE, CRITTER, lP1);
 string sArea = GetName(GetArea(oPC));
 location lPC = GetLocation(oPC);
 string sNear = GetName(GetNearestObject(OBJECT_TYPE_PLACEABLE, oPC, 2));
 object oHole = GetNearestObjectByTag(HOLE);
 object oMap;

 while(GetIsObjectValid(oItem))
 {
    CopyItem(oItem, oCritter, TRUE);
    DestroyObject(oItem);
    oItem = GetNextItemInInventory(oChest);
 }

 SetCampaignInt("TREASURE_CHEST", sName, nCamp++);
 StoreCampaignObject(sName+"TREASURE", "MAP#"+IntToString(nCamp++), oCritter);
 oMap = CreateItemOnObject(MAP, oPC);
 SetName(oMap, sName+" Map #"+IntToString(nCamp++));
 SetDescription(oMap, LEADS+sArea+NEAR+sNear);
 SetLocalInt(oMap, "MAP#", nCamp++);
 SetLocalString(oMap, "MAKER", sName);
 DestroyObject(oHole);
 DestroyObject(oChest);

}



Still working on this, gotta come up with the map thing.
               
               

               


                     Modifié par Baragg, 13 octobre 2010 - 01:49 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #22 on: October 13, 2010, 02:54:25 pm »


               Sorry forgot to put in a check for the invis object, will update the onclose to do that.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #23 on: October 13, 2010, 02:57:13 pm »


               Updated chest onclose:

const string CRITTER  = "nw_ac_pant01";
const string WAYPOINT = "tag_of_waypoint_to_spawn_at";
const string MAP      = "map_resref_here";
const string LEADS    = "This map leads to a treasure, in the area known as ";
const string NEAR     = "The treasure is near ";
const string HOLE     = "hole_tag_here";
const string INVIS    = "tag_of_invisible_object_here";

void main()
{
 location lP1 = GetLocation(GetWaypointByTag(WAYPOINT));
 object oChest = OBJECT_SELF;
 object oItem = GetFirstItemInInventory(oChest);
 object oInvis = GetNearestObjectByTag(INVIS);
 object oPC = GetLastUsedBy();
 string sName = GetName(oPC);
 int nCamp = GetCampaignInt("TREASURE_CHEST", sName, oPC);
 object oCritter = CreateObject(OBJECT_TYPE_CREATURE, CRITTER, lP1);
 string sArea = GetName(GetArea(oPC));
 location lPC = GetLocation(oPC);
 string sNear = GetName(GetNearestObject(OBJECT_TYPE_PLACEABLE, oPC, 2));
 object oHole = GetNearestObjectByTag(HOLE);
 object oMap;

 if(oInvis == OBJECT_INVALID)
 {
  SendMessageToPC(oPC, "You may not bury treasure in this area.");
  return;
 }

 while(GetIsObjectValid(oItem))
 {
    CopyItem(oItem, oCritter, TRUE);
    DestroyObject(oItem);
    oItem = GetNextItemInInventory(oChest);
 }

 SetCampaignInt("TREASURE_CHEST", sName, nCamp++);
 StoreCampaignObject(sName+"TREASURE", "MAP#"+IntToString(nCamp++), oCritter);
 oMap = CreateItemOnObject(MAP, oPC);
 SetName(oMap, sName+" Map #"+IntToString(nCamp++));
 SetDescription(oMap, LEADS+sArea+NEAR+sNear);
 SetLocalInt(oMap, "MAP#", nCamp++);
 SetLocalLocation(oMap, "LOCATION", GetLocation(oChest));
 SetLocalString(oMap, "MAKER", sName);
 SetLocalString(oMap, "AREA", GetTag(GetArea(oPC)));
 DestroyObject(oHole);
 DestroyObject(oChest);

}

               
               

               


                     Modifié par Baragg, 13 octobre 2010 - 02:02 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #24 on: October 13, 2010, 03:31:56 pm »


               This should suffice as the maps onused script. I would suggest that you have two different chest for this system, the first will be the bury chest and the other the retrieval chest, cause they should have two different onclosed scripts. I will make an onclosed for the retrieval next.

#include "x2_inc_switches"
#include "x0_i0_position"

const string WAYPOINT = "tag_of_waypoint_to_spawn_at";
const string CHEST    = "resref_of_chest_to_spawn";
const string HOLE     = "resref_of_hole_to_spawn";

void main()
{
 if(GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE) return;

 object oMap = GetItemActivated();
 object oPC  = GetItemActivator();
 location lHole = GetAheadLocation(oPC);
 location lChest = GetAheadRightLocation(oPC);
 location lWay  = GetLocation(GetWaypointByTag(WAYPOINT));
 string sMArea = GetLocalString(oMap, "AREA");
 location lMLoc = GetLocalLocation(oMap, "LOCATION");
 int nCamp = GetLocalInt(oMap, "MAP#");
 string sName = GetLocalString(oMap, "MAKER");
 string sArea = GetTag(GetArea(oPC));
 location lLoc = GetLocation(oPC);
 object oFirst, oCritter, oChest;

 if(sMArea != sArea)
 {//wrong area
    SendMessageToPC(oPC, "This is not the area this map references.");
    return;
 }

 if(lMLoc != lLoc)
 {//right area wrong location
    SendMessageToPC(oPC, "This is not quite the right location of the treasure.");
    return;
 }

 oCritter = RetrieveCampaignObject(sName+"TREASURE", "MAP#"+IntToString(nCamp), lWay);
 CreateObject(OBJECT_TYPE_PLACEABLE, HOLE, lHole);
 oChest = CreateObject(OBJECT_TYPE_PLACEABLE, CHEST, lChest);

 oFirst = GetFirstItemInInventory(oCritter);

 while(GetIsObjectValid(oFirst))
 {
    CopyItem(oFirst, oChest, TRUE);
    DestroyObject(oFirst);
    oFirst = GetNextItemInInventory(oCritter);
 }

 DeleteCampaignVariable(sName+"TREASURE", "Map#"+IntToString(nCamp));
 DestroyObject(oCritter);
 DestroyObject(oMap);


}

               
               

               


                     Modifié par Baragg, 13 octobre 2010 - 02:32 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #25 on: October 13, 2010, 03:34:54 pm »


               This should be the retrieval chest onclosed, this will keep the chest in existence as long as something is in the chest.

const string HOLE = "tag_of_hole_object_here";

void main()
{
 object o1 = GetFirstItemInInventory(OBJECT_SELF);

 if(GetIsObjectValid(o1)) return;//dont destroy as long as something is in chest

 DestroyObject(GetNearestObjectByTag(HOLE));
 DestroyObject(OBJECT_SELF);
}

               
               

               


                     Modifié par Baragg, 13 octobre 2010 - 02:35 .
                     
                  


            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #26 on: October 14, 2010, 02:21:08 pm »


               I will game test later on in the day still morning here.Ill post results.Looks like it took alot to put this together.......Thanks for taking the time to do so.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #27 on: October 14, 2010, 02:26:27 pm »


               Always a pleasure to assist where I can. I will be mudding walls, taping and floating for a while today so I will check when I get back.
               
               

               
            

Legacy_Dagesh

  • Jr. Member
  • **
  • Posts: 55
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #28 on: October 14, 2010, 04:03:44 pm »


               Scarface has a nice set of bank scripts you may want to look at.



               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #29 on: October 14, 2010, 06:12:17 pm »


               'Posted1.When useing the shovel near a cliff it is possible for the hole and chest to appear over a cliff in a inacessable area making them inacessable.

            A good idea might be to place a script in the on heartbeat of the chest to see if it is opened within 12 seconds.This should give the pc a descent amount of time to open the chest.If not destroy itself and the hole placeable since we dont want either to be left on a map if they are inacessable.The heartbeat would secure inacessable areas and bad spawn spots of the shovel.


'Posted2.The hole seems to spawn in a random spot or near the pc.It seems a little odd because the pc might be crouching low in one direction and then have the hole spawn in a place where he wasnt digging.Perhaps get targeted location would work when useing the shovel,and check if its a vaild location......The chest seems fine spawning at the pcs feet.Otherwise maybe spawning both in the ahead direction work better.


'Posted3.I didnt see a script for the conversation node bury treasue so it was blank during my tests.


'Posted4.I tried both on close scripts on both chests.Currently i have the long script in the spawning chest by the hole,but it doesnt seem to create a map in my inventory.I noticed you have the creation on the map on object and not creature in the long on close script....maybe thats the problem.
               
               

               


                     Modifié par Builder_Anthony, 14 octobre 2010 - 06:27 .