Author Topic: Scrying System by Mannast  (Read 403 times)

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
Scrying System by Mannast
« on: May 17, 2011, 05:14:50 pm »


               Hello all.

So I was looking at this wonderful scrying system on the vault and really really liked the concept (it was much more advanced than my initial attempt to create my own that only showed Online players one could 'scry' on)

anyways, I tried it , liked it and want to use it in my PW.
but it wasnt persistant as it store SetLocalObject on the PC in question.

I asked about a persistant version and he did write one up using the campaign database,etc..
but I wanted to adjust it to better work for a PW...this is where I ask you all some questions that hopefully some local script genius here can answer...

I am using NWNx2 for my persistance...

general questions.
Can/Is it possible to store a SetLocalObject on a no-drop item instead of the PC? thereby not having to change anything about this package except to change object oPC to object oItem for all data read/writes.??

if it IS possible, could you explain any pitfalls to using it this way? it seems it doesnt work for me, but i may be doing it wrong.

if its NOT possible...how could one SetLocalObject within NWNX2 code? I know I can Store an object, but that would just store the object as is into database right? the way the system works roughly is that one can choose to scry say a regular town commoner... then with the SetLocalObject and GetLocalObject the script can then 'find' that object and set up the scry system upon them. anytime within that same game period  but after a reset...bam,...gone....
if I just store the entire object itself then I obviously cannot 'find' that character in the module..man I am confusing myself here...lol

so maybe someone here could take a gander and maybe give me some good advice on how THEY would implement a persistant version of this wonderful system.

'Image'Image'Image'Image'Image
please *wink*
               
               

               
            

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
Scrying System by Mannast
« Reply #1 on: May 17, 2011, 06:26:02 pm »


               should prob. post a link duh...

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

               
            

Legacy_Khuzadrepa

  • Sr. Member
  • ****
  • Posts: 347
  • Karma: +0/-0
Scrying System by Mannast
« Reply #2 on: May 17, 2011, 06:44:45 pm »


               

lordofworms wrote...
general questions.
Can/Is it possible to store a SetLocalObject on a no-drop item instead of the PC? thereby not having to change anything about this package except to change object oPC to object oItem for all data read/writes.??

if it IS possible, could you explain any pitfalls to using it this way? it seems it doesnt work for me, but i may be doing it wrong.

Hey LoW! Yes, you can SetLocalObject on a no-drop item instead of a PC.  I'm not aware of any pitfalls to this, except that storing too many variables (not sure how many) on one object could possibly slow things down a bit.

Could you post a section of code that you've modified?
               
               

               
            

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
Scrying System by Mannast
« Reply #3 on: May 17, 2011, 07:53:42 pm »


               void StoreData(object oPC)
{
string sCDKey = GetPCPublicCDKey(oPC)+GetName(oPC);
object oMod = GetModule();
string sMod = GetLocalString(oMod, "CAMPAIGN");
if(sMod=="") sMod = GetName(oMod);
object oLoc;
int nPersist = GetLocalInt(oMod, "SCRY_PERSIST");
object oJournal = GetItemPossessedBy(oPC, "scrywidget");
if(oJournal!=OBJECT_INVALID)
{
int nNth=1;
oLoc = GetLocalObject(oPC, "ScryLoc_"+IntToString(nNth));//get the first recorded target
while(nNth<=3)//oLoc!=OBJECT_INVALID)
   {
   SetLocalObject(oJournal, "ScryLoc_"+IntToString(nNth), oLoc);
   nNth++;
   oLoc = GetLocalObject(oPC, "ScryLoc_"+IntToString(nNth));//Get the next recorded target
   }
StoreCampaignObject(sMod, sCDKey+"SCRYJOURNAL", oJournal, oPC);
}
}




--------
//"scry_get_data" Scry System v.0.8 by Mannast
//OnEnter - put in Module OnEnter
void main()
{
object oPC = GetEnteringObject();
object oLoc, oMod, oArea;
location lLoc;
string sCDKey = GetPCPublicCDKey(oPC)+GetName(oPC);
string sLoc, sMod;
int nNth =1;
oMod = GetModule();
sMod = GetLocalString(oMod, "CAMPAIGN");
if(sMod=="") sMod = GetName(oMod);
int nPersist = GetLocalInt(oMod, "SCRY_PERSIST");
object oJournal = GetItemPossesssedBy(oPC, "scrywidget");
object oJournal2;
if(oJournal!=OBJECT_INVALID)
{
oJournal2 = RetrieveCampaignObject(sMod, sCDKey+"SCRYJOURNAL", GetLocation(oPC), oPC);
while(nNth<=3)//currently there are only three targets stored - increase this if more are added
   {
       oLoc = GetLocalObject(oJournal2, "ScryLoc_"+IntToString(nNth));
       SetLocalObject(oPC, "ScryLoc_"+IntToString(nNth), oLoc);
   nNth++;
   }
DestroyObject(oJournal, 0.5)//removes extra journal
}
}
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Scrying System by Mannast
« Reply #4 on: May 17, 2011, 08:24:23 pm »


               

Khuzadrepa wrote...

lordofworms wrote...
general questions.
Can/Is it possible to store a SetLocalObject on a no-drop item instead of the PC? thereby not having to change anything about this package except to change object oPC to object oItem for all data read/writes.??

if it IS possible, could you explain any pitfalls to using it this way? it seems it doesnt work for me, but i may be doing it wrong.

Hey LoW! Yes, you can SetLocalObject on a no-drop item instead of a PC.  I'm not aware of any pitfalls to this, except that storing too many variables (not sure how many) on one object could possibly slow things down a bit.

Could you post a section of code that you've modified?


There is a very big pit fall.   To understand what the pit fall is let me first state what is Local Object stored on an item is.   When you store an object on as a Local the only thing that gets stored is the ID of the object.   The problem with trying to use object ID's for presistance is that they are assigned there ID dynamicly. Meaning that no item has an ID untill the game is actualy ran.  The Game gives each item an ID as it is created into the game.   Now an ID can not be given to two different item during the same session of the game, but Items also will not retain there ID's once the server is reset but will be given a new one depending on when the item is created into the game.  
               
               

               
            

Legacy_Khuzadrepa

  • Sr. Member
  • ****
  • Posts: 347
  • Karma: +0/-0
Scrying System by Mannast
« Reply #5 on: May 17, 2011, 08:45:52 pm »


               

Lightfoot8 wrote...
There is a very big pit fall.   To understand what the pit fall is let me first state what is Local Object stored on an item is.   When you store an object on as a Local the only thing that gets stored is the ID of the object.   The problem with trying to use object ID's for presistance is that they are assigned there ID dynamicly. Meaning that no item has an ID untill the game is actualy ran.  The Game gives each item an ID as it is created into the game.   Now an ID can not be given to two different item during the same session of the game, but Items also will not retain there ID's once the server is reset but will be given a new one depending on when the item is created into the game.  

That is a really good point.  I don't use them myself, I just know it's possible to do so.  This is really good to know!
               
               

               
            

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
Scrying System by Mannast
« Reply #6 on: May 17, 2011, 11:47:00 pm »


               I knew there was something funky about that and sincerely thank you Lightfoot for explaining a LocalObject in simple terms..that was one I always had a hard time quite 'understanding' I know I can effectively SetLocal Ints,Strings,Floats, and the like on items and use this technique sparingly but was hoping to simply embed Mannasts systems easily...

so if I may ask Lightfoot, what would you say would be the best way to 'get' these objects..
locations are covered easily enough but actual 'objects' seem to have me stumped (in a persistant version mind you)
I was thinking when selecting an object store the location instead, save Tag, then use a GetLocation of area first, then GetNearestObjectByTag and hope for the best?

or just forbid scrying of 'objects' altogether and stick with location only (I know this is easiest option out but I crave challenges and like the additional RP it will provide me and my friends)
               
               

               


                     Modifié par lordofworms, 17 mai 2011 - 10:48 .
                     
                  


            

Legacy_TSMDude

  • Hero Member
  • *****
  • Posts: 1515
  • Karma: +0/-0
Scrying System by Mannast
« Reply #7 on: May 18, 2011, 12:03:10 am »


               Make the object you wish to scry have a unique variable to it that would be the easiest solution.
               
               

               
            

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
Scrying System by Mannast
« Reply #8 on: May 18, 2011, 12:14:57 am »


               I kinda see..if I set a variable on it like say a name and ascendingnumber system..
worm1,worm2,worm3,etc that would indeed help me find them on load up and during an entire game session
but how would I then reapply those upon a module reload? since those variables would be lost on NPC's etc.when the game closes and is reloaded
Hmmmm...am I overthinking this whole thing? or does this idea become an extremely daunting task for a "medium-to a little more than difficult" self scripter?
               
               

               
            

Legacy_TSMDude

  • Hero Member
  • *****
  • Posts: 1515
  • Karma: +0/-0
Scrying System by Mannast
« Reply #9 on: May 18, 2011, 12:56:42 am »


               Honestly I have not looked. We have our own scrying system so have not checked it out too much that we do with cutscenes. We only allow the NPC thing with DM Interaction because it causes some problems unless you have a item that allows players to nondetect which should also be made to NPCs. (Learned that one the hard way, lol.)
               
               

               
            

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
Scrying System by Mannast
« Reply #10 on: May 18, 2011, 04:06:55 pm »


               Well I *think* I will try my hand at the GetLocation then GetNearestObjectByTag and like I said hope for the best, granted I know this may return the wrong object at times (especially moving objects) but I cannot 'see' any other way to do it, unless someone else here has a suggestion?

I appreciate the help you all have always given.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Scrying System by Mannast
« Reply #11 on: May 18, 2011, 10:33:35 pm »


               I have not looked at the system at all.  So I really do not know why your are storing objects or how they are being selected to be placed as a local object in the first place.  

The first thing I would need to know, in order to even guess at a helpfull solution, Is what type of objects are being stored.  Are they Placeables, Items, Waypoints, Creatures?  Object Is just too diverse of a catagory to take a guess at.  If it is all of the objects above.  You will most likely need to write a section of code to handle the different object types.
               
               

               
            

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
Scrying System by Mannast
« Reply #12 on: May 19, 2011, 01:36:41 am »


               I would say I can handle locations,placeables,(I would just use location since a placeable wouldnt move really?)
the issue is creatures. I dont know how one could 'reload' any type of variable put on them in game on a module reload. since any NPC might wander around..

what the system does simply is a widget that you cast on a location or object.
the object can be a creature(NPC or PC), or a  placeable.
it saves the spot to a slot (in which there are currently 3) upon the widget itself
you can then use a crystal ball to scry the 'stored slot points'
it creates an invisible cutscene you ,immobilized, for a period of time..so you kinda spy on the spot or creature.
if its a creature you autofollow the creature around as an invisible cutscene you..uncommandable.


the placeable like I said I could just use a Set/GetLocation...
but a moving NPC? that might even traverse an area..? thats where I feel like I am hitting a brainblock.
I should also say that this system is not mine,  so I cannot say why he (Mannast) chose to use SetLocalObjects in the first place except he more than likely wrote it for a single player campaign in mind.
but I like everything about it, I like a challenge, I wanted to try to get this persistant and before i strip out the option of being able to scry a creature object I desperately wanted to see if someone here could maybe offer a glimmer of hope with some good advice and perhaps a snippet of code to start me in the right direction. I asked about an event handler once before not far back and the small amount of help allowed me to see that task complete with a smile on my face cause it works waaay better than how I was thinking. and I learned something new..event handlers ..then I looked at old stuff I wrote and found where i could have used them there to be more effective.
I am hoping for that same type of inspiration with this..since , to me, it seems impossible to achieve in a persistant reloading module concept?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Scrying System by Mannast
« Reply #13 on: May 20, 2011, 12:26:31 am »


               I can not think af a single good way to track a randomly selected creature over resets.  One of the main reasons is that there is no way to tell if the creature is even in the game.  Take a selected encounter creature or a creature spawned by a script ot trigger,  After the server resets and the PC reenters the module they are most likely not even created yet.   The only way I can see to pull it off would be to make sure that every creature in the game had a unique tag and not allow any generic creatures to be tracked.  

Sorry I just see no way to track a generic creature or any type of item over server resets.
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Scrying System by Mannast
« Reply #14 on: May 21, 2011, 07:19:26 pm »


               This seems to be an insurmountable problem.  Not even sure exactly what you are exactly trying to do, but maybe something like this:

A PC activates an item, a crystal ball and looking through it scrys a certain location, creature, or placeable.    Maybe one possible solution would be to have the item summon an invisible familiar and then then have the PC auto-posses the creature and have the creature jump to a preselected wp which would be placed in every area you wanted scryable.  Then as the possessed familiar you could float around, thinking of a flying familiar, and look around the area. and you would see what they see. Have the creatures onspawn limit the duration of the spell, by using a delay command destroy object.  What you seems to want is something like atracking device from modern times so you put something on a creature, maybe on spawn, and when you activate your item you can find the creature that has that item on them, but that would be along the lines of giving every creature a unique tag, as how would you differentiate between the items?  You could use Set and Get name I suppose on the item so every Orc would have and item with the unique, for Orcs, item set to their name.  Then you could find all the Orc, or goblins, going through them that way. Just thinking out loud here.


I did one which just gives you the location of every PC in the game when activated.  Of course much less ambitious, and pretty easy compared to what you are trying to do.
               
               

               


                     Modifié par ffbj, 21 mai 2011 - 06:29 .