script for tracking past 72 hours

Post » Sat May 28, 2011 9:38 am

this is an example for a script to track if the player has talked to an NPC. The idea is that after 72 hours the normal dialog checks all reset. this would require MWSE (or MGE since it has internal MWSE). I didn't want to hijack the MCP posts so I put it here and linked to it from the MCP post.

I agree, the one flag is too simplistic. Let's say I have a Redoran type player that visits Vos once in a blue (should that be red?) moon. Why would some smith there remember me because I once asked them to repair my sword over a month ago? Generally I would want an NPC to 'forget' my character unless I interact with them regularly, I think this is best dealt with by mods rather then MCP.


I also put in my 2 cents that this is not necessary for a MCP fix. Seems like it could be remedied with MWSE scripting without too much of a problem. I mean, if you want to run a script on a target without necessarily knowing the object ID of the target it would have to be MWSE, cuz regular vanilla scripting doesn't allow targeted scripts on a variable ID. BUT I don't think you would have to do much and I don't think it would result in a huge FPS hit, either. I'm sure someone can correct this for optimizations, but Something like this running on player:

Begin conversation_keeprlong lookreflong checkrefshort ST_cntl ; control variable for this scriptSetx lookref to xGetPCTargetSetx checkref to lookref->xRefTypeif ( menumode == 1 )	returnendif; check various situations to see if this script should continue processif ( lookref == 0 )        if ( ST_cntl = 2 ) ; this part indicates that you looked away, so reset the ability to run NPC keepr script                       set ST_cntl to 1                       return        endif	set ST_cntl to 0 ;looking at nothing/no target	returnendifset ST_cntl to 1if ( checkref != 1598246990) ; 1598246990 -> is NPC        set ST_cntl to 0        returnendif; verified you are looking at NPC if you got this far in scriptIf ( OnActivate == 0 ) ; to check to make sure you actually TALK to the NPC         return ; this way if you don't it doesn't go on to the remainder of the scriptelse        Activate ; must include to be able to talk to NPCendififx ( ST_cntl )		xSetRef lookref		StartScript, "NPC_keepr"endifend conversation_keepr


and then this should run ONCE and ONCE ONLY on any NPC when you talk to them

Begin NPC_keeprshort has_talkedset has_talked to 1set conversation_keepr.ST_cntl to 2stopscript NPC_keepr; changes control code in other script to 2, so this runs once ; sets the varialbe has_talked on the NPC to 1; then ends and doesn't run again until you look at an NPCEnd NPC_Keepr


ST
ps, since I'm still new at this, I obviously HEAVILY comment my code. Anything this the semicolon in front can be cut out. Also since I'm new at this, there are bound to be ways to change this for even more optimization. go ahead and correct me, cuz I want to learn how to make the code actually run smoother.
User avatar
Natalie Taylor
 
Posts: 3301
Joined: Mon Sep 11, 2006 7:54 pm

Post » Sat May 28, 2011 7:55 am

How does this fix the Talked to PC dialogue filter condition for existing mods? That's kind of the point of making it an (optional) patch.
User avatar
Lilit Ager
 
Posts: 3444
Joined: Thu Nov 23, 2006 9:06 pm

Post » Sat May 28, 2011 12:11 am

How does this fix the Talked to PC dialogue filter condition for existing mods? That's kind of the point of making it an (optional) patch.


Er, I guess it doesn't. What this does is give any NPC a variable that you can test for in dialog testing

ST
User avatar
Becky Palmer
 
Posts: 3387
Joined: Wed Oct 04, 2006 4:43 am

Post » Fri May 27, 2011 10:24 pm

It could work. Do variables in variable-targeted scripts get stored properly? It would seem there would be a conflict somewhere if the NPC already had a script.
User avatar
Laura
 
Posts: 3456
Joined: Sun Sep 10, 2006 7:11 am

Post » Sat May 28, 2011 6:14 am

It could work. Do variables in variable-targeted scripts get stored properly? It would seem there would be a conflict somewhere if the NPC already had a script.


I haven't read anywhere that there could be only one targetted script on an object or NPC - if you run them from another script. This script is a cut of the one I'm trying to finish for my trap project. It basically does the same thing: run a one time script check on certain objects the player looks at. I thought that a simple short variable wouldn't take much memory; and targeted script variables are local to the object the script is run on, so each NPC would have its own. The only thought I have towards making this better is that you wouldn't get to know everyone in the world by just talking to them ONCE; so you could even put in checks to see how many times you talked to a given NPC but this was supposed to be a simple example of an idea I thought would work - but haven't tried out (again, its a chopped up copy of the trap script which is almost at first release status, but there might be a hidden syntax error I didn't see in writing it up)

ST
edit for clarity
User avatar
Ricky Rayner
 
Posts: 3339
Joined: Fri Jul 13, 2007 2:13 am

Post » Sat May 28, 2011 2:19 am

Thing is, do dialogue conditions see all the variables in targetted scripts?

Edit: You should read the http://lovkullen.net/Emma/What_is%20the_72_hours_bug.htm on the bug. It's more than that dialogue condition.
User avatar
Mark Hepworth
 
Posts: 3490
Joined: Wed Jul 11, 2007 1:51 pm

Post » Sat May 28, 2011 6:57 am

Thing is, do dialogue conditions see all the variables in targetted scripts?

Edit: You should read the http://lovkullen.net/Emma/What_is%20the_72_hours_bug.htm on the bug. It's more than that dialogue condition.


Well I took a look in MWSFD v. 9 and it states this:

Dialogue entries come with conditions that you can set in the dialogue editor window. In the
topic window you will find a list of general conditions on the left – here you can define which
Actor (Actor ID) or group of Actors (Race, Class, Disposition, etc.) potentially know this
response. There are also two conditions for the PC (PC faction and rank). To the right you can
set a maximum of 6 "free" conditions that can refer to the Actor, the PC or other things like
the state of global variables – lots of options here, you will have to see for yourself. Check for
journal entries, player stats, local or global variables, items in inventory, and many other
functions, some equivalent to script functions, some unique to dialogue (see below).


I bolded the local variable for that is what is set thru this script: a local variable (local to the NPC). And, in theory; you could define greetings and responses based upon the variable. But, since I'm going off about a script that is theory and I haven't tested I'm going to test this out and get back with you here about it.

ST
User avatar
Nice one
 
Posts: 3473
Joined: Thu Jun 21, 2007 5:30 am

Post » Fri May 27, 2011 10:47 pm

keep in mind, targeted scripts (scripts not attached to the actor and started with startscript) CAN NOT have local variables used as dialog conditionals. you will be allowed to make dialog with those locals as conditionals, but they will never return true.
User avatar
Yama Pi
 
Posts: 3384
Joined: Wed Apr 18, 2007 3:51 am

Post » Fri May 27, 2011 10:09 pm

Yeah, I just found this as well:

Variables defined in a targeted script are not considered local to the object from the point
of view of dialogue and other scripts. For example, they cannot be used as dialogue
conditions
. The special variable "companion" also cannot be used, i.e. declaring a short
variable "companion" in a targeted script and setting it to 1 will not enable companion
share on the target actor. I assume this applies to other special locals as well, but I haven't
tested any others.


Oh, well. It was a nice thought.
ST
User avatar
James Smart
 
Posts: 3362
Joined: Sun Nov 04, 2007 7:49 pm

Post » Sat May 28, 2011 12:21 am

Yeah, I just found this as well:



Oh, well. It was a nice thought.
ST

because so much of my own work is targeted scripts, the way you get around it is transferring the information as a global. for dialog, this is impractical, unless it is for a smallish number of NPCs. you can kind of "cheat it" by using a getdistance to player, but it's a hassle.
User avatar
louise fortin
 
Posts: 3327
Joined: Wed Apr 04, 2007 4:51 am

Post » Sat May 28, 2011 9:01 am

If you want to store state on an NPC, you need to use objects.
User avatar
Ana
 
Posts: 3445
Joined: Sat Jul 01, 2006 4:29 am


Return to III - Morrowind