Aller au contenu

Photo

Using flags to trigger a cutscene


  • Veuillez vous connecter pour répondre
13 réponses à ce sujet

#1
Charsen

Charsen
  • Members
  • 2 266 messages
i have a dialogue where the Warden speaks with an NPC. During the course of the dialogue, a flag is set for the PC.

i have several different plot files: marr_female and marr_male
all of the flags within those plots have the same names: marr_A, marr_B, etc.

So there is a marr_female has its own marr_A and marr_male has its own marr_A.

after the flag is set, when the PC finishes the game by walking out the exit in the great hall, i want a cutscene to play based on that flag. 

ideally, a script would trigger at the end that would have a switch case to go down my list of flags and plot files and play any cutscene that's true. only 1 flag should be true after the dialogue.

is it required that my plot flags are unique, or can i have duplicate names in separate plot files, like i currently do?

can anyone help me with the script for triggering a cutscene based on a flag? i can extrapolate once i have an example. :wizard:

Modifié par Charsen, 07 août 2010 - 10:01 .


#2
FergusM

FergusM
  • Members
  • 460 messages
Off the top of my head I don't know if they can have the same names. It may indeed be a problem.

You could put down a trigger and set its script to something like this:

#include "plt_whatever"
#include "plt_whatever2"
#include "wrappers_h"

void main()
{
event ev = GetCurrentEvent();
switch (GetEventType(ev))
{
case EVENT_TYPE_ENTER:
{
if (IsPartyMember(GetEventCreator(ev)))
{
if (WR_GetPlotFlag(PLT_WHATEVER,SOME_FLAG))
{
CS_LoadCutscene(R"cutscenename.cut");
}
else if (WR_GetPlotFlag(PLT_WHATEVER2,SOME_OTHER_FLAG))
{
CS_LoadCutscene(R"anothercut.cut");
}
DestroyObject(OBJECT_SELF);
//destroy the trigger so it doesn't play again
}
break;
}
}
HandleEvent(ev,RESOURCE_SCRIPT_TRIGGER_CORE);
}

Modifié par FergusM, 07 août 2010 - 10:03 .


#3
Proleric

Proleric
  • Members
  • 2 350 messages
It's best to have unique names for plot flags - I use the plot name as a prefix.

Otherwise, IIRC you'll get a compilation error when using more than one plot header in the same script (which clearly needs to happen in this example).

You can still write common code. In the following example, I know that two plots use the same plot flags. So, instead of using the unique plot flag names, I use a common variable, nFlag. Doesn't save much in this simple case, but savings add up in a larger and more complex script.

if (nValue)
WR_SetPlotFlag(PLT_COCPT_PENDING, nFlag, FALSE, bCallScript);
else
WR_SetPlotFlag(PLT_COCPT_ELIGIBLE, nFlag, FALSE, bCallScript);


Modifié par Proleric1, 08 août 2010 - 07:57 .


#4
Charsen

Charsen
  • Members
  • 2 266 messages
first of all, thanks to both of you. :D

i decided to make all of my flags within the plot files unique. however, having some problems.

plt_marr_quiet_cp is my plot file name, here's my plot file 

i have two different flags in that file which are unique: CPRXDMA and CPRXDML (last letter is different)

here's my code in an image form, reduced and simplified to just two if-statements to illustrate the problem.

i have commented out the CS_LoadCutscene line which had the following problem:
Undefined identifier (CS_LoadCutscene)

if i comment out that line.. i still get this error:Variable defined without type

which occurred while compiling plt_marr_quiet_cp.nss in reference to this line:
                    if (WR_GetPlotFlag(PLT_MARR_QUIET_CP,CPRXDMA))

Checking the wrappers header, i see that the declaration for GetPlotFlag is:
int WR_GetPlotFlag(string strPlot, int nFlag, int nCallScript = FALSE);

so i changed the flag names to the flag # associated in the plot file:
                    if (WR_GetPlotFlag(PLT_MARR_QUIET_CP,0, FALSE))

is this correct? what is the nCallScript and when would it need to be TRUE? why dos CS_LoadCutscene not compile?

Thanks guys. =]

Modifié par Charsen, 08 août 2010 - 01:27 .


#5
Karma

Karma
  • Members
  • 391 messages
A couple things -



As Proleric was saying, as long as the flag numbers are the same, it's more efficient to use common code. Taking that one step further though, if your flags do the exact same thing but for different genders/characters/whatever, you could reference the same script for all those plots. The OC does this for follower approval.



I may be mistaken about which script defines cutscenes, but try including utility_h in your script.

#6
Proleric

Proleric
  • Members
  • 2 350 messages
I suspect the reason that your call to WR_GetPlotFlag isn't compiling is that if you have a plot called x, the toolset generates a header file called plt_x in which the plot string is PLT_X. Since your plot name already begins with plt_, the header file to include is plt_plt_marr_quiet_cp and the plot string is PLT_PLT_MARR_QUIET_CP. This doesn't affect the plot flag names, which you used correctly.

You can answer many questions by looking up the functions in the wiki.

For example, it confirms that CS_LoadCutscene requires the header utility.h.

nCallScript in WR_GetPlotFlag determines whether the plot script is called. It defaults to FALSE, because if you are already in the plot script, calling it again could result in an endless loop. Only set it to TRUE if you are not in the plot script, or you have designed the plot script logic to avoid looping when called for the second time.

If you ever want to get the value of a "defined" flag, you'll have to set nCallScript to TRUE, because "defined" flag values are only calculated in your plot script.

In the companion function WR_SetPlotFlag, nCallScript is especially useful, as you often want to run the plot script to make stuff happen when a certain plot event occurs (being careful not to loop). 

#7
Charsen

Charsen
  • Members
  • 2 266 messages
If i try to use common code by having an essentially duplicated plot file with flag names generated FLAG_0 etc in both files, i get the error:
Likely Duplicate Constant Declaration

Due to the way the header is dumping the flags together before compiling, i must make them unique, i think. (Which is extremely tedious considering due to the tree complexity for the dialogue options, i have 676 flags, or 7 files with 96 flags each. But i am willing to do it by hand if that's what it takes.)

I was assuming nFlag was the Flag number 0-96, but it didn't seem to matter what I put for nFlag. I referenced both the Flag name and separately Flag # and they both compile fine. Which is correct?

Common flags in my plt file

Changed to unique flags per plt file

How do i reference the common flags, FLAG_0, FLAG_1 etc instead of unique flags?

I don't think i am using nFlag correctly. Is this right?

I am using the nFlag for the Flag # in the plt file.

Also, I have seen other scripts that call cutscenes, and they all pass an oHero. My cutscenes all use the player and a companion. Do i need to pass any references to the Warden?

Btw, i added utility_h and that worked for my cs_loadcutscene error, thank you satans_karma. and also Proleric, you were definitely right about the plt_ prefix getting appended on top of the plt_ prefix i added myself. =]

Right now it compiles without error, I am just worried about the nFlag and the use of the oHero object.

Modifié par Charsen, 09 août 2010 - 01:55 .


#8
Karma

Karma
  • Members
  • 391 messages
You do need unique flags as far as I can tell. But what I'm talking about is not your trigger script and using common code there. I'm talking about using an entire common plot event script - the script referenced by each of your plots in the object inspector. That saved me A LOT of time.

Does flag 1 of plot 1 do the exact same thing as flag 1 of plot 2 and so on? If so, you could write one plot event script and reuse it for all your similar plots.

For example: I have two followers Cullen and Jowan. They've got the exact same plot flags (save for the prefix) and the same flag numbers. [CULLEN_INC_APP5 is flag 1 and JOWAN_INC_APP5 is also flag 1] Both flags increase approval by 5. So instead of making a plot event script for each of their respective plots, I made a generic one and had both plots call it. When the plot flag is set, it calls the script. Even if my event case specifies Cullen's flag name, it'll still work for Jowan because they share the same flag number.



Since WR_GetPlotFlag defaults to FALSE for nCallScript where you have it, you don't actually need it. However, I like to throw a == TRUE (or == FALSE) at the end of it for unnecessary organizational purposes. But I think the script you wrote in your second post should compile and work with the proper plot names and adding utility_h in there. As a personal preference, I use the flag names instead of flag numbers (unless of course I'm using common code) that way if I ever need to come back to the script, I can more easily figure out what I was intending.

#9
TimelordDC

TimelordDC
  • Members
  • 923 messages

Charsen wrote...

I was assuming nFlag was the Flag number 0-96, but it didn't seem to matter what I put for nFlag. I referenced both the Flag name and separately Flag # and they both compile fine. Which is correct?


Both are correct. nFlag is the Flag number. Referencing the Flag name or Flag # will allow the script to compile successfully - the reason being, internally, only flag #s are used. The Flag name is declared as a constant within that plot file and assigned the value of the plot flag #.

Charsen wrote...

Due to the way the header is dumping the flags together before compiling, i must make them unique, i think. (Which
is extremely tedious considering due to the tree complexity for the
dialogue options, i have 676 flags, or 7 files with 96 flags each. But
i am willing to do it by hand if that's what it takes.)


676 main flags seem a bit extreme to me. Have you considered using Defined Flags? That should reduce the number of combinations you have to set as main flags; you can use defined flags to do things based on appropriate combinations.
Obviously, I don't know what exactly is it that you are setting so those many flags may be required but just thought I'll throw it out here in case you haven't considered them.

#10
Charsen

Charsen
  • Members
  • 2 266 messages
satans_karma, 

i havent set anything as far as the plot event script yet, it's just plot_core. maybe i'm going about this wrong. i have a trigger set up with a script that reads the flags and activates a cutscene. when the plot flag is set in dialogue, nothing happens, only when they reach the trigger will the plot flags be examined. but each flag is different because each of the flags calls a different cutscene. =/

TimelordDC,

i am not sure what the difference is between a defined and a main flag, or how to use one vs. a main flag. it very well could work, i tried looking up defined flags in the toolset wiki but didn't find much info.
i have 676 flags leading to 676 cutscenes that are extremely similar, save for minor differences. here is the reasoning behind it:

there are 3 different areas. all cutscenes will be in either a chantry, outdoors or in a dwarven interior.

there are 4 attending NPCs, one may be present at any of those locations. 

One of the 4 companions may be present for all of the combinations above.

the warden may either be clothed by the mod or allowed to wear his/her own clothing, 

the companion may either be clothed by the mod or allowed to wear his/her own clothing 

there are 6 different race/gender combinations for each of these above combinations. (DM, DF, EM, EF, HM, HF)

so, for example...
chantry + npc H + alistair + clothing 1 + clothing 1 + DM = cutscene 1
chantry + npc H + alistair + clothing 1 + clothing 1 + DF = cutscene 2
...
outdoors + npc J + zevran + clothing 2 + clothing 1 + HF = cutscene 275

subtracting a few combinations that do not make lore-appropriate sense (non-dwarf Warden in a dwarf interior or with a dwarf NPC) that leaves 676. it is a lot of work, that's why i have been extremely careful in planning it, and in my organization of it. while it is a huge amount, i think it can be done because the changes are so small. in theory, the biggest difference in cutscene creation is the original area and the race/gender tweaks.

the biggest part of the complexity is of course due to the 6 race/gender combos, which is unavoidable, not only because the dummy doesn't allow me to have a proper precision on clipping but also because the formal clothing provided is based on race. a human gets a human noble outfit, etc.

to lower complexity, i have toyed with the idea of just handing the Warden two suits based on the conversation, and they can put the outfits on if they want to use them. 

during dialogue, the PC will talk to an NPC and select the area, the NPC, the companion, etc, and be given a flag according to that choice. then when the Warden walks onto the trigger, the flag will fire up a cutscene which corresponds to the choices in the dialogue. the area, the NPC, the companion choice, and whether the companion and the warden are wearing their own clothes or not. 

i know these are minor details, and i could do this a lot easier, but i had a lot of feedback when planning the mod and am trying to compromise with some things that a lot of people wanted to see. i have the time right now to do it though, i just need to figure out the whole plot flag triggering a cutscene part.
:D

thanks to you both, i really appreciate your responses.

Modifié par Charsen, 10 août 2010 - 02:17 .


#11
Proleric

Proleric
  • Members
  • 2 350 messages
A main flag is set by the builder (in conversation or script).

A defined flag is set in the plot script by evaluating a condition.

For example, you might want a conversation line to appear if the PC is female and any of three main flags has been set. A defined flag is perfect for that.

You might ask in the Cutscene forum about ways of having fewer, more general, cutscenes. I'm no expert, but I believe you can have placeholders for companions, etc.

#12
TimelordDC

TimelordDC
  • Members
  • 923 messages
Charsen, sorry if I am missing something in my post below but here's what I think you should consider:

1. The Warden you are referencing is the player character, I assume. In that case, you do not have to worry about the gender/race/clothes combinations at all. The dummy is just a placeholder in the cutscene and will default to the player character if you set the tag to, IIRC, PLAYER.

2. Alternatively, if by 'clothed by the mod', you mean the player can select a choice in a conversation which will give the player a new set of clothes, just set a flag and equip the clothes on the player before the cutscene. Then, the player will automatically appear in the cutscene with the right clothes.

3. For the companion, again just set a flag for the required companion. In the trigger script, remove all companions except for the one companion whose flag is set; if the companion is not present in the party, add him/her. In the cutscene, you can put in a placeholder tag for the companion too, though I can't recall what it is.

4. If the NPCs are decided during conversation, you can temporarily add them as companions using the same logic above.

Coming to Main vs Defined flags:
Taking the scenario above, you would set Main Flags only for each distinct choice - never for a combination. So, let's say you set plot flags for Alistair (companion), NPC 2 (NPC), Human (Race), Noble (Background), Male (Gender), Chantry (Area), Noble Clothing (clothing).
In the defined flag section, you would do the checks for the combination:
- If Alistair + NPC2 + Human + Chantry + Noble Clothing [note that I leave out the gender and background because the game will automatically handle those things and background has no impact on the appearance], do the following
* check to make sure Alistair is in party
* remove other party members and add NPC2 to party
* unequip current items on PC and equip noble clothing
* play chantry area cutscene

This should technically result in 3 cutscenes for the 3 areas (of course, I may be over-generalizing since I do not know all the options but most are easy to achieve via scripting) or 9 cutscenes if you are going for really fine camera angles due to the height differences.

If you want, I can help you do the required work - creating 676 cutscenes, no matter how similar they are, is tedious work and I hate to think of the resulting download size just because of this :)

#13
Karma

Karma
  • Members
  • 391 messages
Well... instead of the trigger script directly loading and playing the cutscene, you could have the trigger script set a plot flag and call its script. The plot script could be set up to find the correct cutscene for the correct conditions and play it.

so something like:
if (chantry && npc H && alistair && clothing 1 && clothing 1 && DM == TRUE) rCutscene = R"cutscene_1.cut";
else if (chantry && npc H && alistair && clothing 1 && clothing 1 && DF ==TRUE) rCutscene = R"cutscene_2.cut";

CS_LoadCutscene(rCutscene);
PlayCutscene();

Then you could reuse the plot event script for all of your plots. Maybe you could even throw some common code into your trigger script so that you'd only have to write one trigger script.

EDIT: Using defined flags, which get set automatically as soon as all conditions have been met, would make the scripting even easier.

Modifié par satans_karma, 10 août 2010 - 04:38 .


#14
Charsen

Charsen
  • Members
  • 2 266 messages
Ok, lots to consider here... 

First thing -- i can have placeholders, this is true. but the problem is, if you have a scene where the two dummies are interacting, their height differences can and will cause serious clipping if gender/race is not taken into account. it's a sad fact that has been very difficult to overcome. this is why we have dwarf-face-smooshing kisses, and it's been the bane of my modding for months because the default dummy just won't cut it for the tiny details. i am considering tossing the kiss interaction, which would let me use a dummy and would simplify the scene scope tremendously.

however, people expect a kiss at a wedding, i mean, it's a wedding. but i may compromise and do one at a distance or with a clever angle instead of the one i currently have lined up though. i am fine with this solution to lower complexity but it may not be enough due to dwarven height differences.

by clothing, i mean, many of the people who responded to my cutscene videos wanted to see their warden or lover wearing armor, others wanted special, unique formal clothes. i was planning to force the NPC to wear formal clothes if desired, but I am considering putting a placeable chest holding formal clothing outfits in the area and just letting the PC pick what they like before triggering the cutscene.

I know that there are ways to trim this down, that's exactly what i need to learn how to do. there are some details that i need to include in as user-friendly a way as possible. i am fine with adding more work on myself if that means the end user finds the mod easy to use.

basically, at the heart of the plan, i am doing a "quiet wedding" with no audience. it is just the Warden and the spouse-to-be, and an officator of some sort. the PC picks the setting, the officiator, and clothing. people were very adamant about being able to select what they would want to wear. (I later plan to add other wedding scenes, with expanded audiences and locations.)

the cutscenes need some details for semi-fine angles, at least within a few "inches" of precision. I can be creative with the camera too, but i can't hide a dwarf's head in Alistair's chest. =]

i am still trying to research the defined flags. it seems like it's less straight-forward than just setting a single flag and triggering a scene based on that one flag.

and yes, i would actually love some help or to join or make a project. even if it's just a point in the right direction. All i want to do is get a good mod out there that will make folks happy. i have a lot of time on my hands right now, and a lot of motivation, so i'd like to put it to good use. 
:D

Modifié par Charsen, 10 août 2010 - 06:16 .