Aller au contenu

Photo

Is it possible to make new events?


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

#1
JackFuzz

JackFuzz
  • Members
  • 408 messages
Is it possible to make a new event?

Reason: I want to make an event that triggers when a cutscene is about to load, and if I'm lucky an event that fires when the cutscene is complete. 

Then it's VITAL that I know which cutscene is playing.

Workaround: I know that I can just go in and add code to LoadCutscene but I don't want to modify the core files in such a way where it renders my mod incompatible with others.

Modifié par JackFuzz, 23 janvier 2010 - 10:39 .


#2
hunharibo

hunharibo
  • Members
  • 126 messages
You can make new events, but you still have to tell them when to fire - from script.

So instead of adding code to LoadCutscene, you would have to fire the event from LoadCutscene, which still means overriding the core files. But, it might be less damaging to other mods, after all if they dont hook up to your custom event, nothing will happen.

#3
anakin5

anakin5
  • Members
  • 258 messages
You can handle the event EVENT_TYPE_GAMEMODE_CHANGE on you module event handler.



Then, look at the new game mode and make what you want when it is GM_CUTSCENE = 5

#4
JackFuzz

JackFuzz
  • Members
  • 408 messages

anakin5 wrote...

You can handle the event EVENT_TYPE_GAMEMODE_CHANGE on you module event handler.

Then, look at the new game mode and make what you want when it is GM_CUTSCENE = 5


case EVENT_TYPE_GAMEMODE_CHANGE:
        {
            int nNewGameMode = GetEventInteger(ev, 0); // New Game Mode (GM_* constant)
            int nOldGameMode = GetEventInteger(ev, 1); // Old Game Mode (GM_* constant)
            // Insert event-handling code here.
          
            if (nNewGameMode == 5)
            {                  
               // How do I find out the name of the cutscene?
            } 
            if (nOldGameMode == 5)
            {     
                // How do I find out the name of the cutscene?
            }                   
            break;
        }       

Just one more step and ALL my problems are solved lol.

Modifié par JackFuzz, 23 janvier 2010 - 10:12 .


#5
anakin5

anakin5
  • Members
  • 258 messages
void CS_LoadCutsceneWithReplacements(resource rCutscene,
                   string [] arActors,
                   object [] arReplacements,
                   string strPlot = "",
                   int nPlotFlag = -1,
                   string sTalkSpeaker = "")
{
  object oModule = GetModule();

  SetLocalString(oModule, CUTSCENE_SET_PLOT, strPlot);
  SetLocalInt(oModule, CUTSCENE_SET_PLOT_FLAG, nPlotFlag);
  SetLocalString(oModule, CUTSCENE_TALK_SPEAKER, sTalkSpeaker);

  LoadCutscene(rCutscene, OBJECT_INVALID, TRUE, arActors, arReplacements, TRUE);
}

Modifié par anakin5, 23 janvier 2010 - 01:53 .


#6
JackFuzz

JackFuzz
  • Members
  • 408 messages
Anakin,

Yes that is the function that plays cutscenes from utility.h .....

However, my question was if you could find out which cutscene is playing from:

EVENT_TYPE_GAMEMODE_CHANGE

Look at the following code.  If I could get the cutscene CUTSCENE_SET_PLOT & CUTSCENE_SET_PLOT_FLAG I could effectively know which cutscene is playing.

1. Are we able to access the core game resource module from our own module?

case EVENT_TYPE_GAMEMODE_CHANGE:
        {
            int nNewGameMode = GetEventInteger(ev, 0); // New Game Mode (GM_* constant)
            int nOldGameMode = GetEventInteger(ev, 1); // Old Game Mode (GM_* constant)
            // Insert event-handling code here.
          
            if (nNewGameMode == 5)
            {                  
               // How do I find out the name of the cutscene?


            } 
            if (nOldGameMode == 5)
            {     
                // How do I find out the name of the cutscene?


//==================================================
//== FROM CS_LOADCUTSCENE .........................
//==================================================

   object oModule = GetModule();

    GetLocalString(oModule, CUTSCENE_SET_PLOT, strPlot);
    GetLocalInt(oModule, CUTSCENE_SET_PLOT_FLAG, nPlotFlag);

//==================================================

            }                   
            break;
        }   

Modifié par JackFuzz, 23 janvier 2010 - 10:30 .


#7
anakin5

anakin5
  • Members
  • 258 messages
I don't know what is the "name' of a cutscene. There is probably only an ID you can get from the engine.

I don't know if the group of variable PLOT + PLOT_FLAG + TALK_SPEAKER is unique among all cutscene.

Looking at these variable should tell you what cutscene is running, no ?

#8
JackFuzz

JackFuzz
  • Members
  • 408 messages

anakin5 wrote... I don't know what is the "name' of a cutscene.


const resource CUTSCENE_BHN_NIGHT_FALLS         = R"bhn200cs_night_falls.cut";
const resource CUTSCENE_BHN_FINDING_TERYN_BYRON = R"bhn100cs_finding_byron.cut";

anakin5 wrote... There is probably only an ID you can get from the engine.
I don't know if the group of variable PLOT + PLOT_FLAG + TALK_SPEAKER is unique among all cutscene.
Looking at these variable should tell you what cutscene is running, no ?


Yes, how do you look at these variables from your own module?

These look global:

CUTSCENE_SET_PLOT
CUTSCENE_SET_PLOT_FLAG

void CS_CutsceneEnd()
{
    Log_Trace(LOG_CHANNEL_SYSTEMS, "cutscenes_h.nss, CS_CutsceneEnd",
        "CS_CutsceneEnd() called");

    object oModule = GetModule();

    // Get info from last cutscene call
    string sPlot = GetLocalString(oModule, CUTSCENE_SET_PLOT);
    int nFlag = GetLocalInt(oModule, CUTSCENE_SET_PLOT_FLAG);
    string sTalkSpeaker = GetLocalString(oModule, CUTSCENE_TALK_SPEAKER);

    // Reset local variables
    SetLocalString(oModule, CUTSCENE_SET_PLOT, "");
    SetLocalInt(oModule, CUTSCENE_SET_PLOT_FLAG, -1);
    SetLocalString(oModule, CUTSCENE_TALK_SPEAKER, "");


#9
JackFuzz

JackFuzz
  • Members
  • 408 messages
Is there anything like this?



GetMyModule();



GetCoreModule();



??

#10
JackFuzz

JackFuzz
  • Members
  • 408 messages
I figured it out! It works very easily you just use it.

GetModule() gets both your own module and the core module info.

But when I got the Plot string it returns:

C232DA078A044178AA9FCBC6E537FA75

Geez, how do I find that in the plot files under palette.

#11
anakin5

anakin5
  • Members
  • 258 messages
There is no "core module". Your module variable 2da table is merged with the single player varibale 2da table.

CUTSCENE_SET_PLOT and CUTSCENE_SET_PLOT_FLAG are variables in the 2da table of the single player campaign. GetModule() only return "Single player" in your case.



Now I have to ask you what you try to do. For now, I don't understand why you need the "name" of the resource.

I mean, if you need to make something before ALL cutscenes, you don't need to identity which cutscene it is.

And if you need to identity the cutscene, you now have a string which is (may be) unique for each cutscene. (so you can identity it).