Jump to content

Need help with SUBCOMPONENT, GROUP etc.


jastey

Recommended Posts

Hello,

for my NPC mod, I want to make the portrait selection and the kit selection a choice for the player. Obviously, portrait and kit installation alone don't make sense, so the choice should only be there if the whole mod will be installed. And obviously, at least one portrait and kit (or unkitted class) has to be installed so it does work.

How would I code the tp2?

 

Until now, I do BEGIN ~mod~ and for the portrait choice I do

 

BEGIN ~Portrait 1 by Plasmocat~

SUBCOMPONENT ~Ajantis Portrait. Which one do you want to install? (For the default BG portrait press "no")~

 

etc.

 

 

If none is chosen, the default portrait gets installed (this is done in the core content, the portrait gets replaced). Like this, the portrait choice is treated like an own component, and I have to deinstall it manually if the "core" mod gets deinstalled. I would prefer if the portrait and kit installs would get deinstalled automatically if the mod is deinstalled.

 

Would the "require core component" from the BG1NPC project be a choice?

 

So, I would have to copy a file so the other component know it's installed; and for the subcomponents, it would be

 

BEGIN ~core content~

COPY ~BG1NPC/Core/C#component.xx~ ~override/C#AjantisCore.RR~

 

Then the portrait component would be:

 

BEGIN ~Portrait 1 by Plasmocat~

REQUIRE_FILE ~override/C#AjantisCore.RR~

SUBCOMPONENT ~Ajantis Portrait. Which one do you want to install? (For the default BG portrait press "no")~

 

 

?

 

Or is there a better way to do this? When would I use "GROUP" (and how)?

Link to comment
BEGIN ~core content~

COPY ~BG1NPC/Core/C#component.xx~ ~override/C#AjantisCore.RR~

 

Then the portrait component would be:

 

BEGIN ~Portrait 1 by Plasmocat~

REQUIRE_FILE ~override/C#AjantisCore.RR~

SUBCOMPONENT ~Ajantis Portrait. Which one do you want to install? (For the default BG portrait press "no")~

 

 

?

This looks like a typical method used by many. The REQUIRE_FILE goes after SUBCOMPONENT. I personally like to use:

 

REQUIRE_PREDICATE FILE_EXISTS_IN_GAME ~C#AjantisCore.RR~ ~This component requires the core component.~

 

that does exactly the same thing, but this accounts for people deciding they might BIFF their entire override and later install the optional component.

 

Like this, the portrait choice is treated like an own component, and I have to deinstall it manually if the "core" mod gets deinstalled. I would prefer if the portrait and kit installs would get deinstalled automatically if the mod is deinstalled.
If you simply place the optional portrait/kit components after the core component, then someone who uninstalls the core component will automatically, in a FILO (first-in-last-out) manner, uninstall the optional components. If you have your check as above, WeiDU won't be able to re-install the optional components because the core component is gone.
Link to comment

yep; I stole the REQUIRE_PREDICATE FILE_EXISTS_IN_GAME from Ascension64 and pro5 for exactly his given reason.

 

You can also use FORCED_SUBCOMPONENT:

 

/* KIT COMPONENT/SUBCOMPONENTS */
BEGIN ~Jastey is a Wild Mage~
 FORCED_SUBCOMPONENT ~Kit Installation~ (FILE_EXISTS_IN_GAME ~jasteysFlagFile.G3~)
 GROUP ~Install Jastey's Kits and Portraits~
 REQUIRE_FILE ~override/jasteysSecondaryFlagFile.G3~ ~You do not have the Kittable Component installed, so we cannot add a kit~
ACTION_IF FILE_EXISTS_IN_GAME ~FW0100.are~ THEN BEGIN
  COPY_EXISTING ~myFile.cre~ ~override~ 
	  <<patch .cre for kit here>>
END ELSE BEGIN /* BGT Versions */
  COPY_EXISTING ~myFile.cre~ ~override~
	  <<patch .cre for kit here>>
END

BEGIN ~Jastey is a Wonderful Mom~
 FORCED_SUBCOMPONENT ~Kit Installation~ (FILE_EXISTS_IN_GAME ~jasteysFlagFile.G3~)
 GROUP ~Install Jastey's Kits and Portraits~
 REQUIRE_FILE ~override/jasteysSecondaryFlagFile.G3~ ~You do not have the Kittable Component installed, so we cannot add a kit~
ACTION_IF FILE_EXISTS_IN_GAME ~FW0100.are~ THEN BEGIN
  COPY_EXISTING ~myFile.cre~ ~override~ 
	  <<patch .cre for kit here>>
END ELSE BEGIN /* BGT Versions */
  COPY_EXISTING ~myFile.cre~ ~override~
	  <<patch .cre for kit here>>
END

BEGIN ~Jastey is a Cleric of Hanali Celanil/Magic User~
 FORCED_SUBCOMPONENT ~Kit Installation~ (FILE_EXISTS_IN_GAME ~jasteysFlagFile.G3~)
 GROUP ~Install Jastey's Kits and Portraits~
 REQUIRE_FILE ~override/jasteysSecondaryFlagFile.G3~ ~You do not have the Kittable Component installed, so we cannot add a kit~
ACTION_IF FILE_EXISTS_IN_GAME ~FW0100.are~ THEN BEGIN
  COPY_EXISTING ~myFile.cre~ ~override~ 
	  <<patch .cre for kit here>>
END ELSE BEGIN /* BGT Versions */
  COPY_EXISTING ~myFile.cre~ ~override~
	  <<patch .cre for kit here>>
END

BEGIN ~Jastey is a Fighter/Invoker~
 FORCED_SUBCOMPONENT ~Kit Installation~ (FILE_EXISTS_IN_GAME ~jasteysFlagFile.G3~)
 GROUP ~Install Jastey's Kits and Portraits~
 REQUIRE_FILE ~override/jasteysSecondaryFlagFile.G3~ ~You do not have the Kittable Component installed, so we cannot add a kit~
ACTION_IF FILE_EXISTS_IN_GAME ~FW0100.are~ THEN BEGIN
  COPY_EXISTING ~myFile.cre~ ~override~ 
	  <<patch .cre for kit here>>
END ELSE BEGIN /* BGT Versions */
  COPY_EXISTING ~myFile.cre~ ~override~
	  <<patch .cre for kit here>>
END

/* PORTRAIT COMPONENT/SUBCOMPONENTS */
BEGIN ~Jastey With Long Hair~
 FORCED_SUBCOMPONENT ~Portrait Installation~ (FILE_EXISTS_IN_GAME ~jasteysFlagFile.G3~)
 GROUP ~Install Jastey's Kits and Portraits~
 REQUIRE_FILE ~override/jasteysTertiaryFlagFile.G3~ ~You do not have the Portraitable Component installed, so we cannot add a portrait~
  COPY_EXISTING ~myFile.cre~ ~override~ 
	  <<patch .cre for portrait here>>

BEGIN ~Jastey With Short Hair~
 FORCED_SUBCOMPONENT ~Portrait Installation~ (FILE_EXISTS_IN_GAME ~jasteysFlagFile.G3~)
 GROUP ~Install Jastey's Kits and Portraits~
 REQUIRE_FILE ~override/jasteysTertiaryFlagFile.G3~ ~You do not have the Portraitable Component installed, so we cannot add a portrait~
  COPY_EXISTING ~myFile.cre~ ~override~ 
	  <<patch .cre for portrait here>>

BEGIN ~Jastey With Red Hair~
 FORCED_SUBCOMPONENT ~Portrait Installation~ (FILE_EXISTS_IN_GAME ~jasteysFlagFile.G3~)
 GROUP ~Install Jastey's Kits and Portraits~
 REQUIRE_FILE ~override/jasteysTertiaryFlagFile.G3~ ~You do not have the Portraitable Component installed, so we cannot add a portrait~
  COPY_EXISTING ~myFile.cre~ ~override~ 
	  <<patch .cre for portrait here>>

BEGIN ~Jastey With Golden Hair~
 FORCED_SUBCOMPONENT ~Portrait Installation~ (FILE_EXISTS_IN_GAME ~jasteysFlagFile.G3~)
 GROUP ~Install Jastey's Kits and Portraits~
 REQUIRE_FILE ~override/jasteysTertiaryFlagFile.G3~ ~You do not have the Portraitable Component installed, so we cannot add a portrait~
  COPY_EXISTING ~myFile.cre~ ~override~ 
	  <<patch .cre for portrait here>>

BEGIN ~Jastey With No Hair (hey, she has kids... go figure)~
 FORCED_SUBCOMPONENT ~Portrait Installation~ (FILE_EXISTS_IN_GAME ~jasteysFlagFile.G3~)
 GROUP ~Install Jastey's Kits and Portraits~
 REQUIRE_FILE ~override/jasteysTertiaryFlagFile.G3~ ~You do not have the Portraitable Component installed, so we cannot add a portrait~
  COPY_EXISTING ~myFile.cre~ ~override~ 
	  <<patch .cre for portrait here>>

 

 

This will greate the group "Install Jastey's Kits and Portraits"

 

with two separate components, with choices forced (you must install one of the choices on each component, all presented up front):

 

"Kit Installation"

1. Jastey is a Wild Mage

2. Jastey is a Wonderful Mom

3. Jastey is a Cleric of Hanali Celanil/Magic User

4. Jastey is a Fighter/Invoker

 

"Portrait Installation"

1. Jastey With Long Hair

2. Jastey With Short Hair

3. Jastey with Red Hair

4. Jastey With Golden Hair

5. Jastey With No Hair (hey, she has kids... go figure)

 

This was the behavior for the Romance Timers components in Bg1 NPC v12.

 

Or, you can do some fancy READLN stuff; I will be back in a minute...

Link to comment

(I promise, it was for fun, not a planned mod!!! :help: )

 

Shamelessly appropriated from Nythrun's materials;

 

 

EDIT January 4, 2008 - for cmorgan non-logic; now works as intended

 

PRINT ~Selecting Jastey's Hair Status.~

PRINT ~Please choose one of the following:
[1] Jastey as a Blonde.~
[2] Jastey with Blue hair.~
[3] Jastey as a Brunette.~
[4] Jastey with Red hair.~
[5] Jastey after having read cmorgan's latest silliness.~

OUTER_SPRINT ~jasteyportrait~ ~placeholder_value~
OUTER_WHILE (!(IS_AN_INT ~jasteyportrait~) OR (~jasteyportrait~ > 0x5) OR (~jasteyportrait~ < 0x1)) BEGIN
 PRINT PRINT ~Please select 1, 2, 3, 4, or 5 and press enter.~ // This message shows up immediately before player choice, and returns if you fail to press the numbers 1, 2, 3, 4, or 5. It loops until it gets one of the expected values.
 ACTION_READLN ~jasteyportrait~
END
  ACTION_IF ("jasteyportrait" = 1) THEN BEGIN
  COPY ~myMod\PIC\jasteyBlondeLargePic.bmp~ ~jasteyl.bmp~
  COPY ~myMod\PIC\jasteyBlondeSmallPic.bmp~ ~jasteys.bmp~
  PRINT ~Blonde Hair Selected.~
  END
  ACTION_IF ("jasteyportrait" = 2) THEN BEGIN
  COPY ~myMod\PIC\jasteyBlueLargePic.bmp~ ~jasteyl.bmp~
  COPY ~myMod\PIC\jasteyBlueSmallPic.bmp~ ~jasteys.bmp~
  PRINT ~Blue Hair Selected.~
  END
  ACTION_IF ("jasteyportrait" = 3) THEN BEGIN
  COPY ~myMod\PIC\jasteyBrownLargePic.bmp~ ~jasteyl.bmp~
  COPY ~myMod\PIC\jasteyBrownSmallPic.bmp~ ~jasteys.bmp~
  PRINT ~Brunette Hair Selected.~
  END
  ACTION_IF ("jasteyportrait" = 4) THEN BEGIN
  COPY ~myMod\PIC\jasteyRedHeadLargePic.bmp~ ~jasteyl.bmp~
  COPY ~myMod\PIC\jasteyRedHeadSmallPic.bmp~ ~jasteys.bmp~
  PRINT ~Red Hair Selected.~
  END
  ACTION_IF ("jasteyportrait" = 5) THEN BEGIN
  COPY ~myMod\PIC\jasteyBaldLargePic.bmp~ ~jasteyl.bmp~
  COPY ~myMod\PIC\jasteyBaldSmallPic.bmp~ ~jasteys.bmp~
  PRINT ~Bald Is Beautiful Selected.~
  END

Or, of course, if you want to dump the alternate photos in override and change the .cre to relate to the picture instead of the picture to relate to the cre, then

COPY_EXISTING ~myCre.cre~ ~override~

WRITE_ASCII 0x34 ~myPortrait1~ #8 //but make sure it is 8 characters or less

etc.

Link to comment

The last one is cool.

But this line:

OUTER_WHILE (!(IS_AN_INT ~jasteyportrait~) OR (~jasteyportrait~ > 0x5) OR (~jasteyportrait~ < 0x1)) BEGIN ~text~

 

always appears for me! Shouldn't it only appear if a wrong letter / number was chosen?

 

 

 

Some corrections:

 

PRINT ~Please select 1, 2, 3, 4, or 5 and press enter.~

 

PRINT ~Please choose one of the following:

[1] Jastey as a Blonde.~

[2] Jastey with Blue hair.~

[3] Jastey as a Brunette.~

[4] Jastey with Red hair.~

[5] Jastey after having read cmorgan's latest silliness.~

 

OUTER_SPRINT ~jasteyportrait~ ~placeholder_value~

OUTER_WHILE (!(IS_AN_INT ~jasteyportrait~) OR (~jasteyportrait~ > 0x5) OR (~jasteyportrait~ < 0x1)) BEGIN

PRINT PRINT ~Perhaps you had trouble understanding; please try again. Please select 1, 2, 3, 4, or 5 and press enter. This message only shows up if you fail to press the numbers 1, 2, 3, 4, or 5.~

ACTION_READLN ~jasteyportrait~

END

ACTION_IF ("jasteyportrait" = 1) THEN BEGIN

COPY ~myMod\PIC\jasteyBlondeLargePic.bmp~ ~jasteyl.bmp~

COPY ~myMod\PIC\jasteyBlondeSmallPic.bmp~ ~jasteys.bmp~

PRINT ~Blonde Hair Selected.~

END

ACTION_IF ("jasteyportrait" = 2) THEN BEGIN

COPY ~myMod\PIC\jasteyBlueLargePic.bmp~ ~jasteyl.bmp~

COPY ~myMod\PIC\jasteyBlueSmallPic.bmp~ ~jasteys.bmp~

PRINT ~Blue Hair Selected.~

END

ACTION_IF ("jasteyportrait" = 3) THEN BEGIN

COPY ~myMod\PIC\jasteyBrownLargePic.bmp~ ~jasteyl.bmp~

COPY ~myMod\PIC\jasteyBrownSmallPic.bmp~ ~jasteys.bmp~

PRINT ~Brunette Hair Selected.~

END

ACTION_IF ("jasteyportrait" = 4) THEN BEGIN

COPY ~myMod\PIC\jasteyRedHeadLargePic.bmp~ ~jasteyl.bmp~

COPY ~myMod\PIC\jasteyRedHeadSmallPic.bmp~ ~jasteys.bmp~

PRINT ~Red Hair Selected.~

END

ACTION_IF ("jasteyportrait" = 5) THEN BEGIN

COPY ~myMod\PIC\jasteyBaldLargePic.bmp~ ~jasteyl.bmp~

COPY ~myMod\PIC\jasteyBaldSmallPic.bmp~ ~jasteys.bmp~

PRINT ~Bald Is Beautiful Selected.~

END

Link to comment

*bump*

 

When using what cmorgan calls "Shamelessly appropriated from Nythrun's materials", I always get the

"~Perhaps you had trouble understanding; please try again. Please select 1, 2, 3, 4, or 5 and press enter. This message only shows up if you fail to press the numbers 1, 2, 3, 4, or 5.~" line. It shows before the player has the opportunity to type anything at all.

Is there a way to surpress the message until something wrong was actually typed?

Link to comment

I have little experience with such fancy commands, but I would move that line to the end after an ELSE command. Either that or leave it where it is and put an ELSE PRINT (and maybe indeed, that's what should've been there instead of the double PRINT PRINT).

Link to comment
*bump*

 

When using what cmorgan calls "Shamelessly appropriated from Nythrun's materials", I always get the

"~Perhaps you had trouble understanding; please try again. Please select 1, 2, 3, 4, or 5 and press enter. This message only shows up if you fail to press the numbers 1, 2, 3, 4, or 5.~" line. It shows before the player has the opportunity to type anything at all.

Is there a way to surpress the message until something wrong was actually typed?

For important things like choosing the kit, I think it might be better to use subcomponents, so that you can more easily tell what has been chosen by just looking at the WeiDU.log. But to answer your question, sticking another ACTION_READLN ~jasteyportrait~ above the OUTER_WHILE will possibly do what you want.

Link to comment

Too bad there isn't any equivalent of the break command in WeiDU, but you can fix this so:

 

PRINT ~Please select 1, 2, 3, 4, or 5 and press enter.~

PRINT ~Please choose one of the following:
[1] Jastey as a Blonde.~
[2] Jastey with Blue hair.~
[3] Jastey as a Brunette.~
[4] Jastey with Red hair.~
[5] Jastey after having read cmorgan's latest silliness.~

OUTER_SPRINT ~jasteyportrait~ ~placeholder_value~
OUTER_WHILE (!(IS_AN_INT ~jasteyportrait~) OR (~jasteyportrait~ > 0x5) OR (~jasteyportrait~ < 0x1)) BEGIN
ACTION_READLN ~jasteyportrait~
ACTION_IF ("jasteyportrait" = 1) THEN BEGIN
COPY ~myMod\PIC\jasteyBlondeLargePic.bmp~ ~jasteyl.bmp~
COPY ~myMod\PIC\jasteyBlondeSmallPic.bmp~ ~jasteys.bmp~
PRINT ~Blonde Hair Selected.~
END
ACTION_IF ("jasteyportrait" = 2) THEN BEGIN
COPY ~myMod\PIC\jasteyBlueLargePic.bmp~ ~jasteyl.bmp~
COPY ~myMod\PIC\jasteyBlueSmallPic.bmp~ ~jasteys.bmp~
PRINT ~Blue Hair Selected.~
END
ACTION_IF ("jasteyportrait" = 3) THEN BEGIN
COPY ~myMod\PIC\jasteyBrownLargePic.bmp~ ~jasteyl.bmp~
COPY ~myMod\PIC\jasteyBrownSmallPic.bmp~ ~jasteys.bmp~
PRINT ~Brunette Hair Selected.~
END
ACTION_IF ("jasteyportrait" = 4) THEN BEGIN
COPY ~myMod\PIC\jasteyRedHeadLargePic.bmp~ ~jasteyl.bmp~
COPY ~myMod\PIC\jasteyRedHeadSmallPic.bmp~ ~jasteys.bmp~
PRINT ~Red Hair Selected.~
END
ACTION_IF ("jasteyportrait" = 5) THEN BEGIN
COPY ~myMod\PIC\jasteyBaldLargePic.bmp~ ~jasteyl.bmp~
COPY ~myMod\PIC\jasteyBaldSmallPic.bmp~ ~jasteys.bmp~
PRINT ~Bald Is Beautiful Selected.~
END
ACTION_IF (!(IS_AN_INT ~jasteyportrait~) OR (~jasteyportrait~ > 0x5) OR (~jasteyportrait~ < 0x1)) BEGIN
PRINT ~Perhaps you had trouble understanding; please try again. Please select 1, 2, 3, 4, or 5 and press enter. This message only shows up if you fail to press the numbers 1, 2, 3, 4, or 5.~
END
END

Link to comment

Thank you for the help! (Actually, with my (little) coding skills I could have thought of it myself. :) )

 

For important things like choosing the kit, I think it might be better to use subcomponents, so that you can more easily tell what has been chosen by just looking at the WeiDU.log.
That is a good point... Maybe I will change it to subcomponents.
Link to comment

My apologies - my own stupid copy/paste/modify error.

 

Ascension64s way is cool; the original code:

 

  /* Branwen romance timer */
PRINT @1106

PRINT @1102

OUTER_SPRINT ~brantimer~ ~placeholder_value~
OUTER_WHILE (!(IS_AN_INT ~brantimer~) OR (~brantimer~ > 0x5) OR (~brantimer~ < 0x1)) BEGIN
 PRINT @1108
 ACTION_READLN ~brantimer~
END
  ACTION_IF ("brantimer" = 1) THEN BEGIN
  APPEND ~gtimes.ids~ ~3600 BRROM_TIMER~
  PRINT @1109
  END
  ACTION_IF ("brantimer" = 2) THEN BEGIN
  APPEND ~gtimes.ids~ ~2700 BRROM_TIMER~
  PRINT @1110
  END
  ACTION_IF ("brantimer" = 3) THEN BEGIN
  APPEND ~gtimes.ids~ ~1800 BRROM_TIMER~
  PRINT @1111
  END
  ACTION_IF ("brantimer" = 4) THEN BEGIN
  APPEND ~gtimes.ids~ ~900 BRROM_TIMER~
  PRINT @1112
  END
  ACTION_IF ("brantimer" = 5) THEN BEGIN
  APPEND ~gtimes.ids~ ~5400 BRROM_TIMER~
  PRINT @1113
  END

 

with .tra

 

@1108 = ~Please select 1, 2, 3, 4, or 5 and press enter.~

 

@1102 = ~Please choose one of the following:

[1] 1 hour real time (standard) minimum between LoveTalks

[2] 45 minutes real time minimum between LoveTalks

[3] 30 minutes real time minimum between LoveTalks

[4] 15 minutes real time minimum between LoveTalks

[5] 1 hour 30 minutes (extended) real time minimum between LoveTalks~

 

@1106 = ~Select Branwen's Romance Speed:~

 

@1109 = ~Speed: 1 hour real time (standard) minimum between LoveTalks~

@1110 = ~Speed: 45 minutes real time minimum between LoveTalks~

@1111 = ~Speed: 30 minutes real time minimum between LoveTalks~

@1112 = ~Speed: 15 minutes real time minimum between LoveTalks~

@1113 = ~Speed: 1 hour 30 minutes (extended) real time minimum between LoveTalks~

 

I will retest - perhaps we have a hole in our stuff too?

Link to comment
I will retest - perhaps we have a hole in our stuff too?

Why wouldn't it work? It seems designed to keep looping until the user enters a valid choice, so when it's finished, you know the value of brantimer will be one of those 5 values. The fact that the error message (@1108) doesn't look so error-y when first encountered is the big difference between this and your modified one.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...