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

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #30 on: October 15, 2010, 02:19:04 am »


               The item used to activate the new shovel script would just be self activated so no targeting of a location is needed. I added a check to insure there is an item in the chest within a float of 20.0. I made that adjustable you will see in the script where I added a const float. I also added a const string for the holes tag, that will need to be filled in. Please adjust the widget(shovel) to be just activated, not a targeting thing and see how that works.

As to the bury node, there is no need for a script there the need lies in knowing they wish to use the chest or not, if not we need to destroy the objects if they do wish to use it, end the convo and start the loading of loot in the box.
~EDITED THIS PORTION CAUSE OF MY BAD~ Here is the updated "shovel" script wherein I added the check to insure the chest is being used within a certain period of time.
I added in comments to make reading it easier.

#include "x2_inc_switches"
#include "x0_i0_position"

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 HOLE_TAG     = "hole_tag_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 ";
const float TIME  = 20.0;


void ChestCheck(object oChest)
{//used to insure something is in the chest with the alloted time
 object oFirst = GetFirstItemInInventory(oChest);

 if(GetIsObjectValid(oFirst)) return;
 else
 {
  DestroyObject(GetNearestObjectByTag(HOLE_TAG));
  DestroyObject(oChest);
 }
}

void CreateHole(location lP1)
{//spawn hole in front of pc
 CreateObject(OBJECT_TYPE_PLACEABLE, HOLE_OBJECT, lP1);
}

void CreateChest(location lP2)
{//create chest, the later insure something is in it
 object oChest = CreateObject(OBJECT_TYPE_PLACEABLE, CHEST_OBJECT, lP2);
 DelayCommand(TIME, ChestCheck(oChest));
}

void StartConvo(string ConvoRes, object oPC)
{//start the convo twixt the pc and the chest
 object oChest = GetNearestObjectByTag(CHEST_TAG, oPC);
 ActionStartConversation(oChest, CONVO_RES, TRUE, FALSE);
}

void main()
{
 //if not an item activated end here
 if(GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE) return;

 object oPC = GetItemActivator();//get activator

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

 location lP1 = GetAheadLocation(oPC);//get loc in front of pc
 location lP2 = GetAheadRightLocation(oPC);//get loc to front right of pc
 object oChest;//init this object variable

 //dig a bit
 AssignCommand(oPC, PlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 5.0));
 DelayCommand(5.0, CreateHole(lP1));//delay make hole
 DelayCommand(5.1, CreateChest(lP2));//delay make chest
 DelayCommand(5.2, StartConvo(CONVO_RES, oPC));//delay start convo

}

               
               

               


                     Modifié par Baragg, 15 octobre 2010 - 01:25 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #31 on: October 15, 2010, 02:20:45 am »


               As to the map, are you sure you have the resref of the map correct?
               
               

               
            

Legacy_Baragg

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


               This part in the onclosed of the bury chest should create the map on the pc object that closed the chest.

oMap = CreateItemOnObject(MAP, oPC);
               
               

               


                     Modifié par Baragg, 15 octobre 2010 - 01:26 .
                     
                  


            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #33 on: October 15, 2010, 03:32:47 am »


               well my resref is treasuremap i checked it twice but ill redo the testing from scracth making sure i have updated everything then give it a new shot.

As for that line in the script for the map shouldnt it be create item on creature instead of object?
               
               

               


                     Modifié par Builder_Anthony, 15 octobre 2010 - 03:38 .
                     
                  


            

Legacy_Baragg

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


               Looking in the toolset the only 2 create type functions I see are CreateObject, and CreateItemOnObject. I am out the door to go tape and float a room for my mom, I will be back later.
               
               

               
            

Legacy_Builder_Anthony

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


               Ya i ha a late day as well.Probaly skip testing things today.......no huhrry anyways.
               
               

               
            

Legacy_Baragg

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


               Here is the onclosed of the bury chest w/debug lines added. I used a const int DEBUG, so once we have this right we can just change that to anything but 1 and it will shut off the shouts.

const string CRITTER  = "nw_ac_pant01";
const string WAYPOINT = "tag_of_waypoint_to_spawn_at";
const string MAP      = "MAP";
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";
const int    DEBUG    = 1;

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; string sChk;

 if(oInvis == OBJECT_INVALID)
 {
  if(DEBUG == 1)
  {
   SpeakString("Area is invalid for burying loot.", TALKVOLUME_SHOUT);
  }
  SendMessageToPC(oPC, "You may not bury treasure in this area.");
  return;
 }

 while(GetIsObjectValid(oItem))
 {
    CopyItem(oItem, oCritter, TRUE);
    DestroyObject(oItem);
    oItem = GetNextItemInInventory(oChest);
 }
 if(DEBUG == 1)
 {
  SpeakString("Items should now be copied to storage critter.", TALKVOLUME_SHOUT);
 }

 SetCampaignInt("TREASURE_CHEST", sName, nCamp++);
 StoreCampaignObject(sName+"TREASURE", "MAP#"+IntToString(nCamp++), oCritter);
 oMap = CreateItemOnObject(MAP, oPC);
 sChk = GetTag(oMap);
 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);

 if(DEBUG == 1)
 {
  SpeakString("Treasure maps made by this pc, "+IntToString(GetCampaignInt("TREASURE_CHEST", sName)), TALKVOLUME_SHOUT);
  if(GetItemPossessedBy(oPC, sChk) != OBJECT_INVALID)
  {
   SpeakString("Map is on the PC.", TALKVOLUME_SHOUT);
   SpeakString("Map marker int is, "+IntToString(GetLocalInt(oMap, "MAP#")), TALKVOLUME_SHOUT);
   SpeakString("The area tag on the map is, "+GetLocalString(oMap,"AREA"), TALKVOLUME_SHOUT);
  }
  else
  {
   SpeakString("For some reason the map is not created on the map.", TALKVOLUME_SHOUT);
  }

 }

}

               
               

               


                     Modifié par Baragg, 16 octobre 2010 - 12:11 .
                     
                  


            

Legacy_Baragg

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


               I am not sure as to weather or not we should destroy the critter after it is stored out to the db. Probably should.
               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #38 on: October 18, 2010, 05:27:08 pm »


               Debug line
For some reason the map is not creates on the map.

Is there soupposed to be a resref for the area on this lne?
               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #39 on: October 18, 2010, 05:32:45 pm »


               Debug Line
For some reason the map is not created on the map

Is there souppsed to be a resref in this line?
const string AREA = "In the area know as ";

1.Swicthed item to self ony
2.No map created on dm or pc
3.The panther spawns in the area it is soupposed to
4.The delay check for a item works and destroys if no item is in there in 20 sec.
               
               

               


                     Modifié par Builder_Anthony, 18 octobre 2010 - 04:38 .
                     
                  


            

Legacy_Baragg

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


               This is the latest on close of the bury chest:


const string CRITTER  = "nw_ac_pant01";
const string WAYPOINT = "tag_of_waypoint_to_spawn_at";
const string MAP      = "MAP";
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";
const int    DEBUG    = 1;

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; string sChk;

 if(oInvis == OBJECT_INVALID)
 {
  if(DEBUG == 1)
  {
   SpeakString("Area is invalid for burying loot.", TALKVOLUME_SHOUT);
  }
  SendMessageToPC(oPC, "You may not bury treasure in this area.");
  return;
 }

 while(GetIsObjectValid(oItem))
 {
    CopyItem(oItem, oCritter, TRUE);
    DestroyObject(oItem);
    oItem = GetNextItemInInventory(oChest);
 }
 if(DEBUG == 1)
 {
  SpeakString("Items should now be copied to storage critter.", TALKVOLUME_SHOUT);
 }

 SetCampaignInt("TREASURE_CHEST", sName, nCamp++);
 StoreCampaignObject(sName+"TREASURE", "MAP#"+IntToString(nCamp++), oCritter);
 oMap = CreateItemOnObject(MAP, oPC);
 sChk = GetTag(oMap);
 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);

 if(DEBUG == 1)
 {
  SpeakString("Treasure maps made by this pc, "+IntToString(GetCampaignInt("TREASURE_CHEST", sName)), TALKVOLUME_SHOUT);
  if(GetItemPossessedBy(oPC, sChk) != OBJECT_INVALID)
  {
   SpeakString("Map is on the PC.", TALKVOLUME_SHOUT);
   SpeakString("Map marker int is, "+IntToString(GetLocalInt(oMap, "MAP#")), TALKVOLUME_SHOUT);
   SpeakString("The area tag on the map is, "+GetLocalString(oMap,"AREA"), TALKVOLUME_SHOUT);
  }
  else
  {
   SpeakString("For some reason the map is not created on the map.", TALKVOLUME_SHOUT);
  }

 }

}

The strings that you will need to define are:

//waypoint for critter to spawn at
const string WAYPOINT = "tag_of_waypoint_to_spawn_at";

//resref of map here, should have better noted that sorry
const string MAP      = "MAP";

//tag of hole here
const string HOLE     = "hole_tag_here";

//tag of invis object here
const string INVIS    = "tag_of_invisible_object_here";
               
               

               


                     Modifié par Baragg, 18 octobre 2010 - 07:39 .
                     
                  


            

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #41 on: October 18, 2010, 10:17:03 pm »


               I just uploaded a persistant Dig system on the vault using similar ideas, you might want to check it out. it will be at:



http://nwvault.ign.c....Detail&id=1176



when its approved, just uploaded about 15 mins ago. uses a small shovel hak (included) that can be easily removed (coutesy of DOA) .if your looking for hakless prefab. just change the 'shovel' to some other default item and your done.

I wanted to thank Barrag also for some of his own code here was very helpful in me finishing it off . so Thanks. sorry to hijack this thread.
               
               

               
            

Legacy_Builder_Anthony

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


               Used lastest script posted above.A while back you asked if i had the resref of the area correct but i dont see any script calling for a area resref only a waypoint,which i think is for the panther to spawn.So it seems somewhere im missing something.........Have you tested at all?If so is yours running?







Debug Line

For some reason the map is not created on the map







Is there souppsed to be a resref in this line?<-------------------------------------------------------

const string AREA = "In the area know as ";



1.Swicthed item to self ony

2.No map created on dm or pc

3.The panther spawns in the area it is soupposed to

4.The delay check for a item works and destroys if no item is in there in 20 sec.

               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #43 on: October 19, 2010, 03:57:32 am »


               The latest thing does not use the area string, just the waypoint to spawn the critter at.



That string: const string AREA = "In the area know as ";



Will be part of the maps description once it spawns. There are 2 different strings that will be part of the maps description. Let me put some items together and test.
               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Bury gold and retreiving it
« Reply #44 on: October 19, 2010, 04:07:22 am »


               Ya i thought that was a text line....Ok test it out i guess