Where to place markers for NPC scripts?

Post » Fri Apr 18, 2014 11:20 am

Greetings!

I am currently working on a mod that adds books/scrolls/letters/etc to a few NPCs in the game. I talked with Cyran0 about it a while back, and he recommended using my own sound markers to do the job (replacing the sound script with my "add item" scripts). This sounded like a really good idea (less potential for mod conflicts), so I go to work on it.

But now that I am at the point of actually adding the markers to the game, I find myself wondering where to put them. For example, one of the NPCs I'd like to add items to is in a cell with two entrances. Do I need to place the marker on the NPC, or near one (or both) of the doors? I fault my lack of understanding exactly how these sound markers work, ha ha! But seriously, intuitively I want to place them directly on the NPCs, but I don't know if the markers move with them or not. If so, I think we're done here. But if not, I could see a situation where you kill the NPC at a far enough distance from the marker that the script never runs. So, in that case I would think that adding two markers, one by each door, would solve the problem. But I just don't know what the best practice is in this case.

Any ideas? I appreciate any feedback I can get! And please let me know if you need more info. Thanks in advance! :smile:

User avatar
electro_fantics
 
Posts: 3448
Joined: Fri Mar 30, 2007 11:50 pm

Post » Thu Apr 17, 2014 9:37 pm

I've used markers extensively in Desert Region 2. What I did was put the EditorMarker anywhere in the cell and used a CellChanged and a DoOnce condition to do the required action (e.g. a journal update in a new area).

Basically, location doesn't matter unless you use a GetDistance function :)

User avatar
Hilm Music
 
Posts: 3357
Joined: Wed Jun 06, 2007 9:36 pm

Post » Fri Apr 18, 2014 4:26 am

Ahhh, excellent! Yes, that makes good sense. I was already using a DoOnce, but I didn't think about CellChanged. My first guess would be to wrap the CellChanged part inside the DoOnce if/endif... sound about right, or should it be the other way around? (I guess it really doesn't matter much, but I am somewhat concerned with efficiency... seems like the DoOnce condition would be evaluated faster than the CellChanged one... but that's just a guess.)

And thanks again! Very, very helpful! :thanks:

User avatar
Emily abigail Villarreal
 
Posts: 3433
Joined: Mon Aug 27, 2007 9:38 am

Post » Fri Apr 18, 2014 8:25 am

Yeah, CellChanged never failed me. Here's an example:

begin DR2_wererat_scriptshort done If( CellChanged == 0 )If( done == 0 )MessageBox "You hear a strange sound in the room..."Journal EN_Wererat3 10set done to 1endifendif end

iirc it checks if you're in the same cell if equal to 0 and if you left the cell if equal to 1. Very simple but very powerful :D

I put CellChanged before the done condition - so I'm not sure how it'll behave when the if conditions are in a different order.

User avatar
LuBiE LoU
 
Posts: 3391
Joined: Sun Jun 18, 2006 4:43 pm

Post » Thu Apr 17, 2014 10:41 pm

Hmmm... I was just checking http://www.uesp.net/wiki/Tes3Mod:CellChanged out, which seems to indicate the opposite. In other words, it should return 1 when the player character enters the cell. So, it seems like I'd need CellChanged == 1... or am I still missing something? :unsure:

User avatar
Olga Xx
 
Posts: 3437
Joined: Tue Jul 11, 2006 8:31 pm

Post » Thu Apr 17, 2014 11:14 pm

I just checked my mod out in the CS - every time I used a CellChanged function, it was always equal to zero and the journal updates when entering a new area has always worked.

I used CellChanged equal to 1 when detecting if the player's cell has changed (which then disables a priest).

User avatar
naomi
 
Posts: 3400
Joined: Tue Jul 11, 2006 2:58 pm

Post » Fri Apr 18, 2014 2:07 am

I see. Well, perhaps I will play around with it a bit. I looked at a few vanilla scripts that use it, and it appears as though they use CellChanged == 0 for "Return" conditions, and CellChanged == 1 to actually do some work. It's not entirely clear to me just yet, so I think I'll see what different settings do. But this definitely puts me in the right direction, so thank you very much for that! This should take care of it once I get the nuances worked out! :yes:

User avatar
saharen beauty
 
Posts: 3456
Joined: Wed Nov 22, 2006 12:54 am

Post » Fri Apr 18, 2014 10:16 am

CellChanged == 0 works for local scripts in terms of entering the cell. So attaching it to a marker in the cell should work :)

Vanilla scripts mostly use global scripts, so CellChanged == 0 won't work in such scripts (ones which are initiated by StartScript)

User avatar
keri seymour
 
Posts: 3361
Joined: Thu Oct 19, 2006 4:09 am


Return to III - Morrowind