Factions

Everything about development and the OpenMW source code.
User avatar
gus
Posts: 390
Joined: 11 Aug 2011, 15:41

Factions

Post by gus »

I've a questions about scripting.
I'm trying to implement this script instruction: http://www.uesp.net/wiki/Tes3Mod:PCRaiseRank

As you can see, there are 2 possible ways:
PCRaiseRank, "Mages Guild"
PCLowerRank (uses the caller's faction)

So i've 2 questions:
*How do i get the caller faction?
*How is it possible to have different kind of arguments?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Factions

Post by Zini »

*How is it possible to have different kind of arguments?
It is not. But from what I read it isn't necessary. You just need to make the arguments optional (the "/" in the argument list).
*How do i get the caller faction?
I am not entirely sure about the whole faction thing. In loadnpc.hpp I see that an NPC can have only one faction. But I think at least the player can join multiple factions. There is no reason to limit this to the player (which would also be a lot harder to implement). So that means that this value should only be used to initialise new MW-references of type NPC. If that is correct, you need them to add a faction collection (faction and rank) to the NPC CustomData (see mwclass/npc.hpp. For accessing this collection some new functions would have to be added to the mwclass hierarchy.

Note that I based this purely on my memory. I haven't worked with faction stuff for a long time and it is possible that I am remembering wrongly.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Factions

Post by Zini »

Minor correction. The faction state should probably go into NpcStats instead of NPC's CustomData.
User avatar
gus
Posts: 390
Joined: 11 Aug 2011, 15:41

Re: Factions

Post by gus »

For some reasons, script instructions declared in statextensions aren't executed in dialogue script. (No error message, and they work fine in the console).

Any idea?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Factions

Post by Zini »

Nope. Should work. And I am almost certain that you are misinterpreting the failure you are getting. There is no way that switching between console scripts and another script type can make any difference here. Can you explain in more details where it doesn't work for you?
User avatar
gus
Posts: 390
Joined: 11 Aug 2011, 15:41

Re: Factions

Post by gus »

see my branch faction2.

I've added a script instruction which is PCRaiseRank.
When I type it in the console, it works (well it doesn't work, but the script instruction is called).

But when you are talking to some NPC which use this instruction (like when you are joining the fighter guild in balmora), it doesn't work. There is no error (when the intruction is misspeled, it's complaining about unnexpected name, but not here), but the script instruction is never executed.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Factions

Post by Zini »

registerInstruction and registerFunction require the keyword to be all lower case (see the documentation of these function in the header or on my github pages).
User avatar
gus
Posts: 390
Joined: 11 Aug 2011, 15:41

Re: Factions

Post by gus »

I noticed that. But they are lower case. If they are not, it complains because it cannot find the function.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Factions

Post by Zini »

I see the problem. In this particular script the instruction that happens to be located before PCRaiseRank is not parsed correctly. I modified some of the code recently to fix a problem, but apparently I created a new bug while doing so. I will look into this.

btw. I found another bug in the dialogue window. Happens when trying to join the fighters guild. A bit problematic to describe, because we have different localisations. You are given a topic "foo" and afterwards a topic "foo bar". The topic pane on the right side lists both correctly. The main test area highlights only the "foo" part of "foo bar".
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Factions

Post by Zini »

Funny! There seems to be an actual bug in the optional argument handling code (and I will fix it later). But what you are seeing here is not this bug.

The actual dialogue script looks like this (testing on the fighters guild in Balmora):
PCRaiseRank
ModDisposition 5
You have implemented PCRaiseRank. But you don't have ModDisposition, which means compiling this script will fail (and you do get an error message about it; your problem description had me running around in circles for a while). Since the script could not be compiled, it will also not be executed.
Post Reply