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

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Bury gold and retreiving it
« on: October 10, 2010, 04:10:35 am »


               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.
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #1 on: October 10, 2010, 07:19:41 am »


               Feedback on the idea: This would have been so perfect for last month's "pirate" themed custom content challenge. '<img'>
               
               

               
            

Legacy_ehye_khandee

  • Hero Member
  • *****
  • Posts: 1415
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #2 on: October 10, 2010, 12:46:09 pm »


               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
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #3 on: October 11, 2010, 12:06:52 am »


               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.
               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #4 on: October 11, 2010, 04:29:23 am »


               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 .
                     
                  


            

Legacy_Baragg

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


               Sounds cool to me.
               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #6 on: October 11, 2010, 02:07:35 pm »


               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
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #7 on: October 11, 2010, 06:32:07 pm »


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

               
            

Legacy_Baragg

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


               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 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #9 on: October 11, 2010, 07:39:54 pm »


               Changed the above to just use the db.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #10 on: October 11, 2010, 07:46:54 pm »


               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 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #11 on: October 11, 2010, 07:53:12 pm »


               

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).


               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #12 on: October 11, 2010, 08:11:30 pm »


               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 .
                     
                  


            

Legacy_Builder_Anthony

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


               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 .
                     
                  


            

Legacy_Baragg

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


               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 .