• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Solved Random loading screens

Status
Not open for further replies.

modernknight1

Field Marshall of Hot Tubs
Staff member
Storm Modder
Hello to any C coders that may still be hangin around PA!

I am wondering if it would be possible to have multiple loading screens in GOF for events. So just like with music selection, there would be multiple loading screens that would randomly pop up so it isn't always the same picture.

Multiple boarding pictures, multiple death pics, multiple storm, sinking and a battle loading screens.

I think this would make things a lot more interesting.

So far it looks as if the only place this function is governed is in Programs/Seadogs.

Here is one of the germane code strings:

SetEventHandler(EVENT_END_VIDEO,"LaunchMainMenu_afterVideo",0);
PlayStereoOGG("music_ship_dead"); // boal çâóê óáèåíèÿ
switch(sName)
{
case "sea":
/*nSelect = rand(1);
sFileName = "skeleton_on_beach";
switch(nSelect)
{
case 0: sFileName = "skeleton_on_beach"; break;
case 1: sFileName = "undersea"; break;
}
StartPostVideo(sFileName,1); */
StartPictureAsVideo( "loading\seadeath.tga", 3.5 );
break;

case "boarding":
StartPictureAsVideo( "loading\seadeath.tga", 3.5 );
break;

case "land":
StartPictureAsVideo( "loading\death.tga", 3.5 );
break;

case "mutiny":
StartPictureAsVideo( "loading\finalbad2.tga", 3.5 );
break;

case "town":
StartPictureAsVideo( "loading\finalbad1.tga", 3.5 );
break;

case "blood":
StartPictureAsVideo( "loading\finalbad2.tga", 3.5 );
break;
}
}

I'm looking through an old C+ manual now for ideas of how I could do this, but thought someone might have an obvious solution.

I'm wondering if its possible to add cases i.e. "land", "land1", "land2", etc ......but how would land1, etc be triggered? What could I make different?

MK
 
If you are interested in causing a random "case" to be selected. Here is an example ( taken from the Assassin story in POTC ) where a ship is spawned at a random island.

code from quests_reaction.c

case "rocheship":
switch(rand(15))
{
case 0:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "QuebradasCostillas", "Quest_Ships","Quest_Ship_9");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 1:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "FalaiseDeFleur", "Quest_Ships","Quest_Ship_9");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 2:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "Aruba", "Quest_Ships","Quest_Ship_8");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 3:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "Eleuthera", "Quest_Ships","Quest_Ship_9");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 4:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "Turks", "Quest_Ships","Quest_Ship_9");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 5:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "Antigua", "Quest_Ships","Quest_Ship_9");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 6:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "SaintMartin", "Quest_Ships","Quest_Ship_9");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 7:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "Guadeloupe", "Quest_Ships","Quest_Ship_9");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 8:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "Hispaniola", "Quest_Ships","Quest_Ship_9");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 9:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "Cayman", "Quest_Ships","Quest_Ship_9");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 10:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "KhaelRoa", "Quest_Ships","Quest_Ship_8");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 11:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "Douwesen", "Quest_Ships","Quest_Ship_9");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 12:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "Conceicao", "Quest_Ships","Quest_Ship_9");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 13:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "Oxbay", "Quest_Ships","Quest_Ship_9");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 14:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "IslaMuelle", "Quest_Ships","Quest_Ship_9");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;

case 15:
Group_CreateGroup("Roche_Ship");
Group_AddCharacter("Roche_Ship", "Roche Brasiliano");
Group_SetGroupCommander("Roche_Ship", "Roche Brasiliano");
Group_SetAddress("Roche_Ship", "Redmond", "Quest_Ships","Quest_Ship_9");
Pchar.quest.Meet_Rocheship.win_condition.l1 = "NPC_Death";
Pchar.quest.Meet_Rocheship.win_condition.l1.character = "Roche Brasiliano";
Pchar.quest.Meet_Rocheship.win_condition = "capture_roche";
break;
}
break;


Hope this helps.

:cheers
 
Will be possible for sure, ModernKnight. All you need is a switch(rand(NUMBER)) with cases like in Talisman's example. :onya
 
Pieter and Talisman - You're gentlemen and scholars. :checklist

Thank you! :thumbs1

I think this is going to work!

MK
 
Thank you gents! This seems to be working, but I haven't yet seen all of the screens. Also not all of the code for the different kinds of loading screens is in one place, so I'm uncertain if my city building (tavern, shipyard, etc...) screens are working yet.

MK
 
This is working out really nicely and I will show my work soon. Part of my training in development really focused on immersion within simulations. Part of what I'm trying to achieve with all these classic paintings and cool shots is just that.

The last couple of days I have been going after those unique cases that aren't covered in the seadogs.c code. These are individual loading screens that are covered in files that govern the function. So I discovered a little piece of code: RandPhraseSimple. This has allowed me to add an additional random loading screen in many of these specific situations. However, it will only allow me to add the one additional for a total of two possible different views. If I try to add more with commas, none of the loading screens for that function will work at all.

SendMessage(&reload_fader, "ls",FADER_PICTURE, RandPhraseSimple("loading\battle1.tga", "loading\Start_Loading.tga"));

Does anyone know how I can modify this code or add a different code in this circumstance that would allow me to add more options?

MK
 
Last edited:
Would this work?
Code:
SendMessage(&reload_fader, "ls",FADER_PICTURE, RandPhraseSimple(RandPhraseSimple("loading\battle1.tga", "loading\battle2.tga"), "loading\Start_Loading.tga"));

And PotC has this version that allows for three options:
Code:
LinkRandPhrase(DLG_TEXT[284], DLG_TEXT[285], DLG_TEXT[286])
Perhaps that works in CoAS also?
 
This is working Pieter! :thumbs1 I got the additional screens to be accepted as well. The game is more fun and immersive than ever!

There are still a couple of unique cases with the tavern, brothel, and governor yet that may require a different solution, but I will reveal what I run into if I have problems.

Thanks so much for your help once again Mate!!!:cheers

MK
 
OK, Well I have them all figured out now. I'm not finished though. This is extremely time consuming. The way this has to be implemented is each file in Locations.init has to be rewritten. That's a lot of places and a lot of files. I've been at it for the last two days.

The good news about this is that I have picked out multiple unique transition/loading images for each nationalities towns and shores and in some cases forts that are unique only to those locations. I have become very creative with Photoshop. I have imported over a hundred new loading screen images into the game.

One thing that I've noticed about the random effects are that while you are at a particular place, the same transition screens come up over and over again. Its only when you leave and come back that there is a chance of a different set of screens loading. I can live with that.

It's SO much better than having the same loading screen repeat itself over and over throughout the entire game in every place you go. This improvement truly adds some impressive authentic and historical immersion. I think players will be really impressed with the images I've selected and modified and in some cases made myself to help give the game a more realistic and historical feel and flavor. Just another day of coding these files and another improvement knocked off my final list.

Another interesting aside is that while I was modifying the boarding screens I had some troubles. When I finally sorted it out I was able to have multiple boarding and cabin screens for each size of ship, SMALL, MEDIUM, BIG. In the process I found a lot of code I hadn't seen before that I think will help me solve the lower boarding deck problem. I plan to revisit this issue soon and am going to post the relevant files to that topic and a detailed narrative of my changes and attempts in the hopes that the community might help me solve my top priority improvement for the GOF Eras mod.

Thanks again for the help. This topic is solved. :onya

Edit: Oh yeah video coming soon to show my progress...

MK
 
OK so while I am much happier withe what I've built here than original, there is a drawback to using the RandPhraseSimple method. In testing I have found that once the game chooses that image for that location, that its set for the rest of that particular game. I do not like this and so wanted to implement a switch but I don't know how to trigger it....how to get it to recognize it.

I've looked at and experimented with the char definitions in the core file but I can't seem to get it right....

Here's my code...

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
locations[n].id = "SanJuan_tavern";
locations[n].id.label = "Tavern";
locations[n].filespath.models = "locations\inside\tavern03\";
locations[n].image = " SO WHAT DO I PUT IN HERE NOW TO GET THIS TO POINT AT MY STRING AND SWITCH BELOW?";

string loadScr="";
switch (rand(5))
{
case 0 :
loadScr = "loading\Tavern7.tga";
break;
case 1 :
loadScr = "loading\Tavern11.tga";
break;
case 2 :
loadScr = "loading\Party4.tga";
break;
case 3 :
loadScr = "loading\SpanishTavern2.tga";
break;
case 4 :
loadScr = "loading\SpanishTavern5.tga";
break;
}

Some Help please.

MK
 
You're going to have to find the code where the loading screens are used.
Not sure where that is and I can't check right now because I'm far, far away from my computer for the next few days still.

The init code is always set up at the start of the game and whatever you do in those files, it will not change during the game.
Would be nice to add some additional loading screen attributes for you. Should be possible if we can find the relevant code.
 
I have tried all kinds of different commands..... this is so frustrating because it shouldn't be that hard.

MK
 
I think I've got it. In PROGRAM\reload.c find:
Code:
    int loc_pict_index = reload_location_index;
     if(loc_pict_index < 0) loc_pict_index = reload_cur_location_index;
     if(loc_pict_index >= 0)
     {    
       if(CheckAttribute(&Locations[loc_pict_index],"image"))
       {
         if (sGlobalTemp == "afterFDsink")
         {
           SendMessage(&reload_fader, "ls",FADER_PICTURE,"loading\rescue.tga");
           sGlobalTemp = "";
         }
         else
           SendMessage(&reload_fader, "ls", FADER_PICTURE, Locations[loc_pict_index].image);
       }
     }
Replace with:
Code:
    int loc_pict_index = reload_location_index;
     if(loc_pict_index < 0) loc_pict_index = reload_cur_location_index;
     if(loc_pict_index >= 0)
     {    
       if(CheckAttribute(&Locations[loc_pict_index],"image"))
       {
         if (sGlobalTemp == "afterFDsink")
         {
           SendMessage(&reload_fader, "ls",FADER_PICTURE,"loading\rescue.tga");
           sGlobalTemp = "";
         }
         else
         {
           // PB: Random Loading Screens -->
           aref LoadingScreens;
           string LoadingImage;
           makearef(LoadingScreens,Locations[loc_pict_index].image);
           switch(1+rand(GetAttributesNum(LoadingScreens)-1))
           {
             case 1: LoadingImage = Locations[loc_pict_index].image.1; break;
             case 2: LoadingImage = Locations[loc_pict_index].image.2; break;
             case 3: LoadingImage = Locations[loc_pict_index].image.3; break;
             case 4: LoadingImage = Locations[loc_pict_index].image.4; break;
             case 5: LoadingImage = Locations[loc_pict_index].image.5; break;
             LoadingImage = Locations[loc_pict_index].image;
           }
           SendMessage(&reload_fader, "ls", FADER_PICTURE, LoadingImage);
           // PB: Random Loading Screens <--
         }
       }
     }
If you need more than 5 loading screens per location, just add a few more lines to that switch statement above.

You also have to change your location init entries to look like this:
Code:
  Locations[n].image.1 = "loading\Tavern7.tga";
  Locations[n].image.2 = "loading\Tavern11.tga";
  Locations[n].image.3 = "loading\Party4.tga";
  Locations[n].image.4 = "loading\SpanishTavern2.tga";
  Locations[n].image.5 = "loading\SpanishTavern5.tga";
You only have to do this with the ones where you've got multiple loading screens.
Single-screen locations still work fine with the old code setup.

I have tested this in PotC and it works fine. The above code is adapted to work in CoAS, but I didn't actually test it in there.
 
You are awesome Pieter! :bow

That's exactly what I needed! Thanks so much once again. This will probably take me a whole day to implement reindexing the images inventory and then rewriting the locations init files, but it will be well worth it!

MK
 
This will probably take me a whole day to implement reindexing the images inventory and then rewriting the locations init files, but it will be well worth it!
I was afraid that might be quite a bit of work. Can't think of any other way to handle this though. :(
 
Status
Not open for further replies.
Back
Top