Bury gold and retreiving it
#1
Posté 10 octobre 2010 - 03:10
This is a script request along with a request for feedback or suggestions to improve the idea itself.
#2
Posté 10 octobre 2010 - 06:19
#3
Posté 10 octobre 2010 - 11:46
Be well. Game on.
GM_ODA
#4
Posté 10 octobre 2010 - 11:06
#5
Posté 11 octobre 2010 - 03:29
Modifié par Builder_Anthony, 11 octobre 2010 - 03:31 .
#6
Posté 11 octobre 2010 - 11:44
#7
Posté 11 octobre 2010 - 01:07
Script Request
#8
Posté 11 octobre 2010 - 05:32
#9
Posté 11 octobre 2010 - 06:27
#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
Posté 11 octobre 2010 - 06:39
#11
Posté 11 octobre 2010 - 06:46
#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
Posté 11 octobre 2010 - 06:53
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
Posté 11 octobre 2010 - 07:11
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
Posté 11 octobre 2010 - 07:26
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
Posté 12 octobre 2010 - 12:45
Thanks for the clarify Lightfoot8. Sometimes I forget to check the lexi.
Modifié par Baragg, 12 octobre 2010 - 12:46 .
#16
Posté 12 octobre 2010 - 12:47
#17
Posté 12 octobre 2010 - 09:13
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
Posté 12 octobre 2010 - 04:14
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
Posté 12 octobre 2010 - 08:12
#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
Posté 12 octobre 2010 - 08:14
#21
Posté 13 octobre 2010 - 12:19
- ------>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
Posté 13 octobre 2010 - 01:46
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
Posté 13 octobre 2010 - 01:54
#24
Posté 13 octobre 2010 - 01:57
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
Posté 13 octobre 2010 - 02:31
#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 .





Retour en haut






