Aller au contenu

Photo

Bury gold and retreiving it


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

#26
Baragg

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


#27
Builder_Anthony

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

#28
Baragg

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

#29
Dagesh

Dagesh
  • Members
  • 30 messages
Scarface has a nice set of bank scripts you may want to look at.




#30
Builder_Anthony

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


Posted Image2.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.


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


Posted Image4.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 .


#31
Baragg

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


#32
Baragg

Baragg
  • Members
  • 271 messages
As to the map, are you sure you have the resref of the map correct?

#33
Baragg

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


#34
Builder_Anthony

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


#35
Baragg

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

#36
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
Ya i ha a late day as well.Probaly skip testing things today.......no huhrry anyways.

#37
Baragg

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


#38
Baragg

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

#39
Builder_Anthony

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

#40
Builder_Anthony

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


#41
Baragg

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


#42
lordofworms

lordofworms
  • Members
  • 252 messages
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.

#43
Builder_Anthony

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


#44
Baragg

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

#45
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
Ya i thought that was a text line....Ok test it out i guess

#46
Baragg

Baragg
  • Members
  • 271 messages
Tested using the following, I did change the definition of nCamp a bit so as to clarify a bit, but the following did spawn a book on my PC upon closing the chest, I use a book resref cause I did not have a map item. Are you sure you are using an item resref and not a placeable? If so are you 100% sure you have the resref right they are case sensitive.

const string CRITTER  = "nw_malekid01";
const string WAYPOINT = "test";
const string MAP      = "nw_it_book022";
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    = "NW_IT_BOOK010";
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;
 nCamp = nCamp++;

 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, oPC);
 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);
  }

 }

}


I only tested this script, and not the rest of them using the resrefs and such that are listed in here.

Modifié par Baragg, 19 octobre 2010 - 03:08 .


#47
Baragg

Baragg
  • Members
  • 271 messages
Just retested, and it worked but did notice there is a need to add an empty string spot in front of the "The treasure is near ", it should be " The treasure is near ". So that it is not right up against the previous string in the description. Lol, it said the treasure was near the Dirt Patch, cause that is the nearest placeable. Kinda neat seeing that work like that.

#48
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
Ill have to check every tag and resref then.I take it you received the man then if you have that text pop up because i havent seen it.I souppose its from useing the map.Oh....yes it is a item for the map i am usen.

Modifié par Builder_Anthony, 19 octobre 2010 - 03:27 .


#49
Baragg

Baragg
  • Members
  • 271 messages
Well that text actually becomes the description of the map.

IE: You "examine" the map item in your inventory and the description says

"This map leads to a treasure in the area know as Blah.The treasure is near Dirt Patch."

That is the description that my map(book) has now. I did notice that some of the campaign int settings may be off. I will have to check on that some more. Let us know what you come up with, If need be I can send you the lil module I am using to develop this. Tomorrow morn I have to go fix some windshield wipers for a man. I will check in after that.

Blah is the name of the area I am testing in.

Modifié par Baragg, 19 octobre 2010 - 03:33 .


#50
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
Please send the mod to boulderopalhunter2008@gmail.com