Greetings.
I've been working on a dialogue and got some questions.
To summarize, I borrowed the npc spawn code from an online tutorial (you probably have seen or heard it, it was a merchant spawn).
This code basically checks for the npc in the area and spawns it if it's not there.
I slightly changed the code a few times to see what I can do with it very simply. For example, I made it check if sten was there, I made it display a floating message about a plot flag status...
Now, it doesn't work. The merchant spawn does, but I can't get it to display anything. Not only that, but also one of my plot flags is apparently Set on start, eventhough it's supposed to be not-set.
There are some assumptions of mine on how these work. For example, I assume that, each time I load a game, the flag starts from its first condition. So, say, if I load a game, do something to change that flag then quit the game and later on load that save to check something, its value isn't the last value.
By the way, the reason I load games is because that's the only way I know how to test stuff. It's an NPC, dialogue-based test in camp, so i keep loading a save in campsite.
Here are my questions:
1-) When I place an 2da file (PRCSCR_one) to load a script for that area, does it require an area transition? Or simply loading the area loads it? I assume it must be the latter. However, there has been a few times when a script didn't fire when I loaded my camp save, but worked when I traveled to another spot and re-entered camp. Got me confused. Or is it just random problem or some problem because of bad code?
///////////////////////////////
#include "wrappers_h" (i dont know what this includes actually:P)#include "plot_h" (included when I tried getting plot flags. not sure if needed)#include "plt_csc_plt_traveler_dlg" (again, this is included because I tried getting plot flags from the file)#include "utility_h" (included to troubleshoot a few problems, probably not really needed)void main(){object oPlayer = GetMainControlled();object oMerchant = UT_GetNearestObjectByTag(oPlayer, "csc_traveler");if (!IsObjectValid(oMerchant)){object oArea = GetObjectByTag("cam100ar_camp_plains");location lMerchantLocation = Location(oArea, Vector(166.61, 124.77, -1.33), 85.4);CreateObject(OBJECT_TYPE_CREATURE, R"csc_traveler.utc", lMerchantLocation);
}
/////////////////////////////////
2) How right am I about the plot flag values? Does it reset each time you load a game? I mean it should. It actually works with one of the flags. While talking you have a chance to learn something from him, which unlocks some options. This always works. However, as i said, there is a flag that is meant to be not set initially, but behaves as if its set. I checked its situation by assigning the plot to a conversation child condition. Now I can easily change set/not set values in the conversation, but I don't understand why it doesn't start as a not-set value. Any ideas on what could cause this?
3) What is the best way to test mods? I'm mostly doing conversations, so I think I'll be able to test them if I set a stage and all.
4) Is there a way to search the conversation to find Conditions and/or Actions? Or use of a certain flag? Or the only way is the expand and check all branches?
5) Is my method of spawning npc any good? Any advices or suggestions on that? I'm quite the noob with modding, so I don't know the general way modders take.
I think I skipped a question or two, I'll post them later.
Question about flags/conversations/scripts
Débuté par
ArathWoeeye
, janv. 29 2010 08:32
#1
Posté 29 janvier 2010 - 08:32
#2
Posté 29 janvier 2010 - 09:06
1) The area load event is fired when the player transitions to an area from another area, not when the player "loads" a save game within the area.
2) I'm not quite sure what you're asking about plot flags, so I'll try and explain. When you load a save game, plot flag values are whatever they were when you made that save. If you save, set some flags then load without saving, the flags set after the save will be reset. However, flags do not reset to their original values. Plot flags are they principle way progress through the game is tracked. If they reset when the game was load, all progress would be lost.
3) It depends what you need to test. I tend to make a save game as close to my change as possible, but in another area before I've ever entered the changed area. If the change is to a script or conversation file, then this isn't necessary and the save can be directly next to the change. For some kinds of changes, you need to start a new game and use cheat commands to quickly progress to the area in question. Unfortunately, understanding what is a safe way to test requires an understanding of what dats is saved into the save game and what is global and outside of the save.
4) In the conversation editor, press ctrl f to search. Press the Show Fields button to expand a list of fields to search. You can check or uncheck the action and condition plots and plot flags to search for whatever you want.
5) If what you want is to add an NPC to the main campaign in a way which will be compatable with other people's mods, then yes, that's a good way. If you aren't interseted in compatability, you could directly edit the main campaign module and place your NPC in the area. This wouldn't be compatible with any save game that had already entered the area however. For making large changes intended for future playthroughs, this method would likely be simpler than spawning creatures in dynamicaly however.
2) I'm not quite sure what you're asking about plot flags, so I'll try and explain. When you load a save game, plot flag values are whatever they were when you made that save. If you save, set some flags then load without saving, the flags set after the save will be reset. However, flags do not reset to their original values. Plot flags are they principle way progress through the game is tracked. If they reset when the game was load, all progress would be lost.
3) It depends what you need to test. I tend to make a save game as close to my change as possible, but in another area before I've ever entered the changed area. If the change is to a script or conversation file, then this isn't necessary and the save can be directly next to the change. For some kinds of changes, you need to start a new game and use cheat commands to quickly progress to the area in question. Unfortunately, understanding what is a safe way to test requires an understanding of what dats is saved into the save game and what is global and outside of the save.
4) In the conversation editor, press ctrl f to search. Press the Show Fields button to expand a list of fields to search. You can check or uncheck the action and condition plots and plot flags to search for whatever you want.
5) If what you want is to add an NPC to the main campaign in a way which will be compatable with other people's mods, then yes, that's a good way. If you aren't interseted in compatability, you could directly edit the main campaign module and place your NPC in the area. This wouldn't be compatible with any save game that had already entered the area however. For making large changes intended for future playthroughs, this method would likely be simpler than spawning creatures in dynamicaly however.
#3
Posté 29 janvier 2010 - 09:23
Thank you for your answers David. I realize some questions are a bit puzzling, but that's because I'm more than puzzled myself, quite new to all this.
I can't believe I missed such a basic search function, I got lost in the interface it seems.
I'm interested in compatability indeed, good to know it's a good way.
These raise another question for me. Let's pretend I have a script that works with the conversation in the camp. Well, no need to pretend that's how it is. If someone enters the camp.. but doesn't do anything. Save the game.. then quit and load the game to continue tomorrow.. then the script won't fire and it won't work at all? Or is the "state" somehow saved in the save file? If it's not saved, how is a modder supposed to work around that? Should I use different methods?
PS: To make it clearer, what I want is an NPC that will stay in the camp, like bodahn and sandal. He will have different dialogue branches as the game progresses.
I can't believe I missed such a basic search function, I got lost in the interface it seems.
I'm interested in compatability indeed, good to know it's a good way.
These raise another question for me. Let's pretend I have a script that works with the conversation in the camp. Well, no need to pretend that's how it is. If someone enters the camp.. but doesn't do anything. Save the game.. then quit and load the game to continue tomorrow.. then the script won't fire and it won't work at all? Or is the "state" somehow saved in the save file? If it's not saved, how is a modder supposed to work around that? Should I use different methods?
PS: To make it clearer, what I want is an NPC that will stay in the camp, like bodahn and sandal. He will have different dialogue branches as the game progresses.
Modifié par ArathWoeeye, 29 janvier 2010 - 09:24 .
#4
Posté 31 janvier 2010 - 03:24
I'll do a double post to bump a new question that confuses me without a new topic.
I have a very interesting situation. I think some of my confusion above came from the inconsistency.
I have 4 flags in my plot, main flags and they are all "non set" initially. Now 3 of them work as intended. But one of them start as set.
Only place I set that flag is a dialogue branch. But that dialogue branch's.. uhm.. upper branch only shows if that flag is not set. So it's supposed to go like "flag is unset, dialogue shows up. take that dialogue, set the flag, now it won't show up".
I suspected I could have a general problem with flags, but all other flags work exactly how I mean them to.
I know this seems to blind to put a finger on, but any ideas? Maybe someone experienced a similar problem?
I have a very interesting situation. I think some of my confusion above came from the inconsistency.
I have 4 flags in my plot, main flags and they are all "non set" initially. Now 3 of them work as intended. But one of them start as set.
Only place I set that flag is a dialogue branch. But that dialogue branch's.. uhm.. upper branch only shows if that flag is not set. So it's supposed to go like "flag is unset, dialogue shows up. take that dialogue, set the flag, now it won't show up".
I suspected I could have a general problem with flags, but all other flags work exactly how I mean them to.
I know this seems to blind to put a finger on, but any ideas? Maybe someone experienced a similar problem?
#5
Posté 02 février 2010 - 03:48
How are you testing these flags. Is it from a save game? Have you previously deleted any flags from this plot?
I ask because of the way flags are stored. The game doesn't care what a flags name is, only what it's number is. If you delete a flag and add a new one, it re-uses the number, so a previous save game could already have set that flag to be some valuel, even though think you're working with a new flag.
Other than that, I'm drawing a blank, but it's hard for me to tell where you're going wrong without being able to look over what you've done.
I ask because of the way flags are stored. The game doesn't care what a flags name is, only what it's number is. If you delete a flag and add a new one, it re-uses the number, so a previous save game could already have set that flag to be some valuel, even though think you're working with a new flag.
Other than that, I'm drawing a blank, but it's hard for me to tell where you're going wrong without being able to look over what you've done.
#6
Posté 02 février 2010 - 04:27
First of all, let me say I found a workaround. I'll explain it all.
I have a plot file, a conv file and a script. This script is loaded on party camp (normal one) via 2DA files.
In the plot file, all flags are main flags and start as unset. In the conversation, I have used flags to hide and reveal dialogue branches. For example first branch only shows when flag 0 (I'll refer flags as F0, F1) is unset. The other two options are shown when f0 is set. And the first line of the first branch sets f0. So only the first branch shows at first and it never shows up again.
When I want to test this, I load a save game in Soldier's Peak (now that I learned 2da's load scripts when transition is made) then move to camp. I never save those games. I'm sure of this because all other flags are in their starting values, instead of new values.
I've a small while loop in the 2da-bound script file that takes all values of flags and adds them in a string. So I know the values of flags before the conversation. 2nd flag, in this case is always 1. I had 4 flags and my string was 0100. Now I've more and it's 0100000 etc.
The script file is very small and it has no code that alters the second flag.
Funny thing is, I have created another flag, then changed all of Flag2 values into Flag4 values in my conversation. So, flag 4 is used in conversation and flag 2 isn't used anywhere in the code. And it works. Flag4 starts as 0. Flag2, on the other hand, still starts as 1.
So I just left the flag there and named it WEIRDOFLAG.
I have another question by the way.
What exactly does "GetNearestObjectByTag" do? And UT_GetNearestObjectByTag? I used UT one to check with emissaries (I wanted different dialogue based on emissaries) but even if I don't have the werewolf emissary in camp, it behaves as if it's there.
To be exact:
//////////////////
oEmis = UT_GetNearestObjectByTag(oPlayer, "lite_camp_emiss_were");
if (IsObjectValid(oEmis))
{
WR_SetPlotFlag("csc_plt_traveler_dlg",10,TRUE);
WR_SetPlotFlag("csc_plt_traveler_dlg",11,TRUE);
}
///////////////////////
I have a plot file, a conv file and a script. This script is loaded on party camp (normal one) via 2DA files.
In the plot file, all flags are main flags and start as unset. In the conversation, I have used flags to hide and reveal dialogue branches. For example first branch only shows when flag 0 (I'll refer flags as F0, F1) is unset. The other two options are shown when f0 is set. And the first line of the first branch sets f0. So only the first branch shows at first and it never shows up again.
When I want to test this, I load a save game in Soldier's Peak (now that I learned 2da's load scripts when transition is made) then move to camp. I never save those games. I'm sure of this because all other flags are in their starting values, instead of new values.
I've a small while loop in the 2da-bound script file that takes all values of flags and adds them in a string. So I know the values of flags before the conversation. 2nd flag, in this case is always 1. I had 4 flags and my string was 0100. Now I've more and it's 0100000 etc.
The script file is very small and it has no code that alters the second flag.
Funny thing is, I have created another flag, then changed all of Flag2 values into Flag4 values in my conversation. So, flag 4 is used in conversation and flag 2 isn't used anywhere in the code. And it works. Flag4 starts as 0. Flag2, on the other hand, still starts as 1.
So I just left the flag there and named it WEIRDOFLAG.
I have another question by the way.
What exactly does "GetNearestObjectByTag" do? And UT_GetNearestObjectByTag? I used UT one to check with emissaries (I wanted different dialogue based on emissaries) but even if I don't have the werewolf emissary in camp, it behaves as if it's there.
To be exact:
//////////////////
oEmis = UT_GetNearestObjectByTag(oPlayer, "lite_camp_emiss_were");
if (IsObjectValid(oEmis))
{
WR_SetPlotFlag("csc_plt_traveler_dlg",10,TRUE);
WR_SetPlotFlag("csc_plt_traveler_dlg",11,TRUE);
}
///////////////////////
#7
Posté 02 février 2010 - 04:53
Can you post your PRCSCR script?
As for UT_GetNearestObjectByTag, keep in mind that creatures are generally placed in whatever areas they appear, just set inactive until needed. You'd need to add a check for GetObjectActive(oEmis) if you want to know whether he will appear in the game.
As for UT_GetNearestObjectByTag, keep in mind that creatures are generally placed in whatever areas they appear, just set inactive until needed. You'd need to add a check for GetObjectActive(oEmis) if you want to know whether he will appear in the game.
Modifié par Craig Graff, 03 février 2010 - 08:28 .
#8
Posté 02 février 2010 - 04:59
Okay thanks. I guessed as much. Wasn't sure how to overcome it. Here is the code, I'll add a few comments:
/////////////////////////////This is the spawning script for 1st companion, traveler
#include "wrappers_h"
#include "plot_h"
#include "plt_csc_plt_traveler_dlg"
#include "utility_h"
void main(){
object oPlayer = GetMainControlled();
object oTraveler = UT_GetNearestObjectByTag(oPlayer, "csc_traveler");
if (!IsObjectValid(oTraveler)){
object oArea = GetObjectByTag("cam100ar_camp_plains");
location lTravelerLocation = Location(oArea, Vector(166.61, 124.77, -1.33), 85.4);
CreateObject(OBJECT_TYPE_CREATURE, R"csc_traveler.utc", lTravelerLocation);}
//above is the code I found from a website to spawn a merchant, if there isn't any, used it to spawn my traveler
object oEmis;
oEmis= UT_GetNearestObjectByTag(oPlayer, "lite_camp_emiss_eamon");
if (IsObjectValid(oEmis)){ WR_SetPlotFlag("csc_plt_traveler_dlg",5,TRUE); WR_SetPlotFlag("csc_plt_traveler_dlg",11,TRUE);
}
oEmis= UT_GetNearestObjectByTag(oPlayer, "lite_camp_emiss_dwarf");
if (IsObjectValid(oEmis)){
WR_SetPlotFlag("csc_plt_traveler_dlg",6,TRUE);
WR_SetPlotFlag("csc_plt_traveler_dlg",11,TRUE);
}
oEmis= UT_GetNearestObjectByTag(oPlayer, "lite_camp_emiss_tranq");
if (IsObjectValid(oEmis)){ WR_SetPlotFlag("csc_plt_traveler_dlg",8,TRUE); WR_SetPlotFlag("csc_plt_traveler_dlg",11,TRUE);
}
oEmis = UT_GetNearestObjectByTag(oPlayer, "lite_camp_emiss_dalish");
if (IsObjectValid(oEmis)){
WR_SetPlotFlag("csc_plt_traveler_dlg",9,TRUE);
WR_SetPlotFlag("csc_plt_traveler_dlg",11,TRUE)
;}
oEmis = UT_GetNearestObjectByTag(oPlayer, "lite_camp_emiss_were");
if (IsObjectValid(oEmis)){
WR_SetPlotFlag("csc_plt_traveler_dlg",10,TRUE);
WR_SetPlotFlag("csc_plt_traveler_dlg",11,TRUE);
}
string hede="";
int g=0; int i=0;
while (i!=12){ g=WR_GetPlotFlag("csc_plt_traveler_dlg",i); hede+=/*tToString(i)*/GetPlotFlagName("csc_plt_traveler_dlg",i)+IntToString(g)+" "; i++;
}
DisplayFloatyMessage(oPlayer, hede, FLOATY_MESSAGE, 16777215, 20.0);
//When I enter the camp first, it displays 1 for the 2nd flag (WEIRDO) and 1 for each emissary
//I mistakenly had an entry for a golem emissary which returned 0 too, deleted it when I realized they hadn't a //seperate emissary}
/////////////////////////////This is the spawning script for 1st companion, traveler
#include "wrappers_h"
#include "plot_h"
#include "plt_csc_plt_traveler_dlg"
#include "utility_h"
void main(){
object oPlayer = GetMainControlled();
object oTraveler = UT_GetNearestObjectByTag(oPlayer, "csc_traveler");
if (!IsObjectValid(oTraveler)){
object oArea = GetObjectByTag("cam100ar_camp_plains");
location lTravelerLocation = Location(oArea, Vector(166.61, 124.77, -1.33), 85.4);
CreateObject(OBJECT_TYPE_CREATURE, R"csc_traveler.utc", lTravelerLocation);}
//above is the code I found from a website to spawn a merchant, if there isn't any, used it to spawn my traveler
object oEmis;
oEmis= UT_GetNearestObjectByTag(oPlayer, "lite_camp_emiss_eamon");
if (IsObjectValid(oEmis)){ WR_SetPlotFlag("csc_plt_traveler_dlg",5,TRUE); WR_SetPlotFlag("csc_plt_traveler_dlg",11,TRUE);
}
oEmis= UT_GetNearestObjectByTag(oPlayer, "lite_camp_emiss_dwarf");
if (IsObjectValid(oEmis)){
WR_SetPlotFlag("csc_plt_traveler_dlg",6,TRUE);
WR_SetPlotFlag("csc_plt_traveler_dlg",11,TRUE);
}
oEmis= UT_GetNearestObjectByTag(oPlayer, "lite_camp_emiss_tranq");
if (IsObjectValid(oEmis)){ WR_SetPlotFlag("csc_plt_traveler_dlg",8,TRUE); WR_SetPlotFlag("csc_plt_traveler_dlg",11,TRUE);
}
oEmis = UT_GetNearestObjectByTag(oPlayer, "lite_camp_emiss_dalish");
if (IsObjectValid(oEmis)){
WR_SetPlotFlag("csc_plt_traveler_dlg",9,TRUE);
WR_SetPlotFlag("csc_plt_traveler_dlg",11,TRUE)
;}
oEmis = UT_GetNearestObjectByTag(oPlayer, "lite_camp_emiss_were");
if (IsObjectValid(oEmis)){
WR_SetPlotFlag("csc_plt_traveler_dlg",10,TRUE);
WR_SetPlotFlag("csc_plt_traveler_dlg",11,TRUE);
}
string hede="";
int g=0; int i=0;
while (i!=12){ g=WR_GetPlotFlag("csc_plt_traveler_dlg",i); hede+=/*tToString(i)*/GetPlotFlagName("csc_plt_traveler_dlg",i)+IntToString(g)+" "; i++;
}
DisplayFloatyMessage(oPlayer, hede, FLOATY_MESSAGE, 16777215, 20.0);
//When I enter the camp first, it displays 1 for the 2nd flag (WEIRDO) and 1 for each emissary
//I mistakenly had an entry for a golem emissary which returned 0 too, deleted it when I realized they hadn't a //seperate emissary}
Modifié par ArathWoeeye, 02 février 2010 - 05:01 .
#9
Posté 02 février 2010 - 05:07
GetNearestObjectByTag returns an array of all creatures in the current area wth the given tag, sorted by distance to the specificied object.
UT_GetNearestObjectByTag returns the object in the current area which both has the given tag and is closest to the speicified object.
The UT version is more convenient if you only want one creature, and runs much faster if you're worried about performance. I'd only use GetNearestObjectByTag if you want to do something to multiple creatures that have the same tag, and you care about their distance from some object.
UT_GetNearestObjectByTag returns the object in the current area which both has the given tag and is closest to the speicified object.
The UT version is more convenient if you only want one creature, and runs much faster if you're worried about performance. I'd only use GetNearestObjectByTag if you want to do something to multiple creatures that have the same tag, and you care about their distance from some object.
#10
Posté 02 février 2010 - 09:57
Bookmarked! Thanks to all contributors.
#11
Posté 03 février 2010 - 08:15
Craig Graff wrote...
Can you post your PRCSCR script?
As for UT_GetNearestObjectByTag, keep in mind that creatures are generally placed in whatever areas they appear, just set inactive until needed. You'd need to add a check for IsObjectActive(oEmis) if you want to know whether he will appear in the game.
For future reference, I've discovered that "IsObjectActive" doesnt exist, it's GetObjectActive.
From the editor:
int GetObjectActive (
object oObject
)
Parameters:
oObject
- The object query status on
Returns:
non-zero if active, zero if inactive





Retour en haut






