Aller au contenu

Photo

Bury gold and retreiving it


  • Veuillez vous connecter pour répondre
50 réponses à ce sujet

#1
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
Figure it be nice if a player could dig a hole and bury a small chest to hide some belongings.Acting as a persistent chest the chest would store the location of the spot once activated by a conversation and somehow be recalled from being dug up to retreive the belongins of the chest.

This is a script request along with a request for feedback or suggestions to improve the idea itself.

#2
The Amethyst Dragon

The Amethyst Dragon
  • Members
  • 1 873 messages
Feedback on the idea: This would have been so perfect for last month's "pirate" themed custom content challenge. :)

#3
ehye_khandee

ehye_khandee
  • Members
  • 855 messages
BA, Yes, it _is_ a fun feature (we got that too), on ArgentumRegio. VERY handy when you've got too much loot to carry - and is a great excuse for a tie-in with treasure maps.



Be well. Game on.

GM_ODA

#4
Baragg

Baragg
  • Members
  • 271 messages
Do you have a shovel? You could store the location in a db, then have your shovels on used event check the db, and the location of the pc if the match bang dig up chest.

#5
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
I souppose i could make one.Its a neat little idea.Ehye has a good idea about tieing it to maps as well.Mybe the data base could unlock a treasure location for the shovel.In fact maybe just give the pc a map once he digs to bury the treasure....that way the map can be traded to other players or stolen by pickpockets.

Modifié par Builder_Anthony, 11 octobre 2010 - 03:31 .


#6
Baragg

Baragg
  • Members
  • 271 messages
Sounds cool to me.

#7
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
I guess there also has to be a limitaion on where a pc can dig.I think it be best if the script checked for a invisable item non useable that was in the area.So just drop this invisable object into a wilderness area and the pc can dig anywhere on a 16x16 map.This would keep them from digging in 2nd story buildings.



Script Request

#8
Baragg

Baragg
  • Members
  • 271 messages
Using setlocalobject or storecampaignobject will save out the items in the inventory also correct?

#9
Baragg

Baragg
  • Members
  • 271 messages
I am not sure this will store the items in the container out, but here is a shot at a shovel script, you would target the item you wish to bury with the "shovel". It then creats a map on the pc, there are two options as to the storing of the object, one is setlocalobject, that sets it to the map, the other stores it to the database. Tagbased script:

#include "x2_inc_switches"

const string MAP_OBJECT = "map_resref_here";
const string INVIS_OBJECT = "invisible_object_tag_here";
const string NEAR_OBJECT = "This map leads to a buried treasure, near ";
const string AREA_OBJECT = "In the area know as ";

void main()
{
 int nChk = GetUserDefinedItemEventNumber();

 if(nChk != X2_ITEM_EVENT_ACTIVATE) return;

 object oTar = GetItemActivatedTarget();
 location lLoc = GetLocation(GetItemActivator());
 object oMap = CreateItemOnObject(MAP_OBJECT, GetItemActivator());
 string sArea = GetName(GetArea(GetItemActivator()));
 object oNear = GetNearestObject(OBJECT_TYPE_PLACEABLE, GetItemActivator());
 object o1 = GetFirstItemInInventory(oTar);
 string sName = GetName(GetItemActivator());
 int nCount = GetCampaignInt(sName+"_MAPS", "NUM_O_MAPS", GetItemActivator());

 if(GetTag(oNear) == INVIS_OBJECT) oNear = GetNearestObject(OBJECT_TYPE_PLACEABLE,
  oNear);

 SetCampaignInt(sName+"_MAPS", "NUM_O_MAPS", nCount++);
 SetLocalLocation(oMap, "TREASURE", lLoc);
 SetName(oMap, sName+"s' Map #"+IntToString(nCount++));
 SetDescription(oMap, NEAR_OBJECT+GetName(oNear)+"."+AREA_OBJECT+GetName(GetArea(GetItemActivator())));
 SetLocalObject(oMap, "TREASURE_CHEST", oTar);

 //comment out the above setlocalobject and comment in the following to use
 //the database functions

 //SetLocalInt(oMap, "MAP#", nCount++);
 //StoreCampaignObject(sName+"MAPS", "MAP#"+IntToString(nCount++), oTar);

 while(GetIsObjectValid(o1))
 {
    DestroyObject(o1);
    o1 = GetNextItemInInventory(oTar);
 }

 DestroyObject(oTar);


}

Modifié par Baragg, 11 octobre 2010 - 06:29 .


#10
Baragg

Baragg
  • Members
  • 271 messages
Changed the above to just use the db.

#11
Baragg

Baragg
  • Members
  • 271 messages
This would be the map usage tagbased script, both this and the shovel script are untested:

#include "x2_inc_switches"
#include "x3_inc_string"

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

 object oPC = GetItemActivator();
 location lPC = GetLocation(oPC);
 object oMap = GetItemActivated();
 location lMap = GetLocalLocation(oMap, "TREASURE");
 int nChk = GetLocalInt(oMap, "MAP#");
 string sName = GetName(oMap);
 sName = StringParse(sName);


 if(lPC == lMap)
 {//if pc location is the map location
    RetrieveCampaignObject(sName+"MAPS", "MAP#"+IntToString(nChk), lPC, oPC);
    DestroyObject(oMap);
 }
 else
 {
    SendMessageToPC(oPC, "No, this is not the correct location");
 }

}

Modifié par Baragg, 11 octobre 2010 - 06:47 .


#12
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

Baragg wrote...

Using setlocalobject or storecampaignobject will save out the items in the inventory also correct?


This is incorrect, 

Per the lexcion on StoreCampaignObject

Stores an item or creature in the campaign database. Campaign names are case-sensitive. Returns 1 if successful, 0 if the function fails. Only items or creatures can be stored using this function.



Per the lexicon on SetLocalObject.


Remarks
Note that the Campaign version actually copies information from the game to the database - this, however, stores a local objects "identifier". For this reason, because now local variables can be set on a PC's items and be persistant, any GetLocalObject() calls after the server has reset and it is retrieved from the item will return an odd, or totally invalid object reference (the default OBJECT_INVALID will be returned).



#13
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
1.Still seting things up but i noticed if i target myself with the shovel all items disappear.
2.Targeting a single item makes a single item disappear.
3.Targeting a useable placeable makes it disappear.
4.I dont think the map is being created into the pcs inventory

Would it be easier to just open a small box or bag and just insert items after the shovel is used?

Modifié par Builder_Anthony, 11 octobre 2010 - 07:23 .


#14
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
Shovel is tagbased unique power unlimited uses
Map is unique power self only
Invisable object is plot and static


1.Still seting things up but i noticed if i target myself with the shovel all items disappear.
2.Targeting a single item makes a single item disappear.
3.Targeting a useable placeable makes it disappear.
4.I dont think the map is being created into the pcs inventory

Would it be easier to just open a small box or bag and just insert items after the shovel is used?

Modifié par Builder_Anthony, 11 octobre 2010 - 07:41 .


#15
Baragg

Baragg
  • Members
  • 271 messages
Mayhap have the shovel spawn in a "treasure chest" at the pcs location, and upon that chest being closed it is "buried". Lol, I had not even thought of someone targeting themselves with the shovel, kinda mafia of you to target someone like that with a shovel. If we go the spawn in a chest to hold stuff method I am now convinced we will need to store the items in it on a critter then set that critter out as a local to the campaign db. Then when the map is used spawn in the chest and copy the items off the critter to the chest. Sorry, I been hanging sheet rock all day, and will get on this rewrite tomorrow after I return home.

Thanks for the clarify Lightfoot8. Sometimes I forget to check the lexi.

Modifié par Baragg, 12 octobre 2010 - 12:46 .


#16
Baragg

Baragg
  • Members
  • 271 messages
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.

#17
tmanfoo

tmanfoo
  • Members
  • 85 messages
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.


#18
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
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

#19
Baragg

Baragg
  • Members
  • 271 messages
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 .


#20
Baragg

Baragg
  • Members
  • 271 messages
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.

#21
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
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

#22
Baragg

Baragg
  • Members
  • 271 messages
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 .


#23
Baragg

Baragg
  • Members
  • 271 messages
Sorry forgot to put in a check for the invis object, will update the onclose to do that.

#24
Baragg

Baragg
  • Members
  • 271 messages
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 .


#25
Baragg

Baragg
  • Members
  • 271 messages
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 .