Jump to content

How to check what game the mod is being installed on?


Recommended Posts

For the mods I've made, I have had to make three versions: BG1EE, BG2EE and IWDEE. It would be easier if I could just fit all three in one file, especially since most of the code is the same, its just that there's one or two files unique to each.

I want to put IF statements to check what game is being installed but I'm not sure how I would do that.

Link to comment

It's easier if you post the mod content so the specific code can be provided, but you can designate specific files for games by doing something like this:

ACTION_IF GAME_IS ~BGEE BG2EE IWDEE~ THEN BEGIN

COPY ~%MOD_FOLDER%/items/filename.itm~ OVERRIDE

END

 

Link to comment
20 minutes ago, Artemius I said:

It's easier if you post the mod content so the specific code can be provided, but you can designate specific files for games by doing something like this:


ACTION_IF GAME_IS ~BGEE BG2EE IWDEE~ THEN BEGIN

COPY ~%MOD_FOLDER%/items/filename.itm~ OVERRIDE

END

 

For example, I have a mod for the Shapeshifter kit:

 

    ACTION_IF FILE_EXISTS_IN_GAME ~brbrp.itm~ BEGIN
        COPY_EXISTING ~brbrp.itm~ ~override~

This is for the werewolf forms paw attack in BG1, in each game the file is named differently. So with that code I would start with:

ACTION_IF GAME_IS ~BGEE BG2EE IWDEE~ THEN BEGIN
    ACTION_IF FILE_EXISTS_IN_GAME ~brbrp.itm~ BEGIN
        COPY_EXISTING ~brbrp.itm~ ~override~

END

now I would need an ELSE IF statement. According to Weidu, I can do ELSE but I cant find anything for ELSE IF:
 

ACTION_IF GAME_IS ~BGEE BG2EE IWDEE~ THEN BEGIN
    ACTION_IF FILE_EXISTS_IN_GAME ~brbrp.itm~ BEGIN
        COPY_EXISTING ~brbrp.itm~ ~override~

END ELSE

ACTION_IF FILE_EXISTS_IN_GAME ~cdbrbrp.itm~ BEGIN  // PAW ATTACK FOR bg2
    COPY_EXISTING ~cdbrbrp.itm~ ~override~

 

Now I need to able to put the one for IWD. Does ELSE_IF work in weidu?

 

 

 

Link to comment
20 minutes ago, gamemaster76 said:

Does ELSE_IF work in weidu?

You don't need one ! As you can use multiple ACTION_IF's...

As in, you don't need to declare what you would like to happen if the game is Robocop 2073:

ACTION_IF GAME_IS ~BGEE~ THEN BEGIN
...
END

ACTION_IF GAME_IS ~BG2EE~ THEN BEGIN
...
END

ACTION_IF GAME_IS ~IWDEE~ THEN BEGIN
...
END

And probably have multiple folders for the games each that store their own .itm's etc files that they need, so you can just COPY the entirety of the folder in one action(in case the files don't need any further modification, like names).

Edited by Jarno Mikkola
Link to comment
18 minutes ago, Jarno Mikkola said:

You don't need one ! As you can use multiple ACTION_IF's...

As in, you don't need to declare what you would like to happen if the game is Robocop 2073:



ACTION_IF GAME_IS ~BGEE~ THEN BEGIN
...
END

ACTION_IF GAME_IS ~BG2EE~ THEN BEGIN
...
END

ACTION_IF GAME_IS ~IWDEE~ THEN BEGIN
...
END

And probably have multiple folders for the games each that store their own .itm's etc files that they need, so you can just COPY the entirety of the folder in one action(in case the files don't need any further modification, like names).

Huh.. yeah that makes sense actually. I'm more used to C language where you NEED else_if or else the program has a heart attack... according to my old teachers anyway 😂

So the need for else_if was kinda drilled into me.

Edited by gamemaster76
Link to comment
3 hours ago, Jarno Mikkola said:

You don't need one ! As you can use multiple ACTION_IF's...

As in, you don't need to declare what you would like to happen if the game is Robocop 2073:



ACTION_IF GAME_IS ~BGEE~ THEN BEGIN
...
END

ACTION_IF GAME_IS ~BG2EE~ THEN BEGIN
...
END

ACTION_IF GAME_IS ~IWDEE~ THEN BEGIN
...
END

And probably have multiple folders for the games each that store their own .itm's etc files that they need, so you can just COPY the entirety of the folder in one action(in case the files don't need any further modification, like names).

 

 

Wait, if I understood correctly, then where the [...] is I have to copy the same code over and over again? Thats exactly what I'm trying to avoid with ELSE_IF:

Right now I have this in one part of my code, each one needs a different resource:

ACTION_IF GAME_IS ~BGEE~ THEN BEGIN // For BG1EE
    LAUNCH_PATCH_FUNCTION ~ALTER_SPELL_EFFECT~ // LINKS TRANSFORMATION WITH CORRECT PAW ATTACK
          INT_VAR
            check_globals = 1
            check_headers = 1
            header = 1
            header_type = 1
            match_opcode = 111
            timing = 2
          
          STR_VAR 
            resource = ~BRBRP2~
        END     
END
        
ACTION_IF GAME_IS ~BG2EE~ THEN BEGIN    // For BG2EE
    LAUNCH_PATCH_FUNCTION ~ALTER_SPELL_EFFECT~ // LINKS TRANSFORMATION WITH CORRECT PAW ATTACK
          INT_VAR
            check_globals = 1
            check_headers = 1
            header = 1
            header_type = 1
            match_opcode = 111
            timing = 2
          
          STR_VAR 
            resource = ~CDBRBRP3~
        END 
END        
        
ACTION_IF GAME_IS ~IWDEE~ THEN BEGIN // For IWDEE
    ACTION_IF FILE_EXISTS_IN_GAME ~werewlf1.itm~ BEGIN
        COPY_EXISTING ~werewlf1.itm~ ~override~
        
        LAUNCH_PATCH_FUNCTION ~ALTER_SPELL_EFFECT~ // LINKS TRANSFORMATION WITH CORRECT PAW ATTACK
          INT_VAR
            check_globals = 1
            check_headers = 1
            header = 1
            header_type = 1
            match_opcode = 111
            timing = 2
          
          STR_VAR 
            resource = ~werewlf3~
        END 
END        

 

This is fine because its just one LPF, but for the rest what I need is:

            // adds paw attack for Lesser Werewolf form

ACTION_IF FILE_EXISTS_IN_GAME ~brbrp.itm~ BEGIN        // For BG1EE
                    COPY_EXISTING ~BRBRP.ITM~ ~override/brbrp2.ITM~ 


ACTION_IF FILE_EXISTS_IN_GAME ~cdbrbrp.itm~ BEGIN   // For BG2EE
                    COPY_EXISTING ~cdbrbrp.itm~ ~override/cdbrbrp3.itm~
                    
                    
ACTION_IF FILE_EXISTS_IN_GAME ~werewlf1.itm~ BEGIN // For IWDEE
                    COPY_EXISTING ~werewlf1.itm~ ~override/werewlf3~

 

LAUNCH_PATCH_FUNCTION ~ALTER_ITEM_HEADER~ // dice size and dice thrown
              INT_VAR
              check_globals = 1
              check_headers = 1
                header = 1
                header_type = 1
                dicesize  = 12
                dicenumber = 1
                damage_bonus = 0
            END

[.....] (a LOT of LPF code like the above one. of which is exactly the same in all 3 versions)

 

I don't want to paste the same sections of code 3 times for each difference, it will be too long.

Edited by gamemaster76
Link to comment

Also 

PACTHACTION_IF GAME_IS ~BGEE~ THEN BEGIN // For BG1EE
    LAUNCH_PATCH_FUNCTION ~ALTER_SPELL_EFFECT~ // LINKS TRANSFORMATION WITH CORRECT PAW ATTACK
          INT_VAR
            check_globals = 1
            check_headers = 1
            header = 1
            header_type = 1
            match_opcode = 111
            timing = 2
          
          STR_VAR 
            resource = ~BRBRP2~
        END     
END

causes a parse error:

 

Parse error (state 232) at LAUNCH_PATCH_FUNCTION

[SETUP-BALANCED_SHAPESHIFTER_KIT.TP2] PARSE ERROR at line 70 column 8-28
Near Text: LAUNCH_PATCH_FUNCTION
        GLR parse error

[SETUP-BALANCED_SHAPESHIFTER_KIT.TP2]  ERROR at line 70 column 8-28
Near Text: LAUNCH_PATCH_FUNCTION
        Parsing.Parse_error
ERROR: parsing [SETUP-BALANCED_SHAPESHIFTER_KIT.TP2]: Parsing.Parse_error
ERROR: problem parsing TP file [SETUP-BALANCED_SHAPESHIFTER_KIT.TP2]: Parsing.Parse_error

FATAL ERROR: Parsing.Parse_error

 

 

 

 

Nevermind this one, found PATCH_IF was a thing that existed 

Edited by gamemaster76
Link to comment
3 hours ago, gamemaster76 said:

 

ACTION_IF FILE_EXISTS_IN_GAME ~brbrp.itm~ BEGIN        // For BG1EE
                    COPY_EXISTING ~BRBRP.ITM~ ~override/brbrp2.ITM~ 


ACTION_IF FILE_EXISTS_IN_GAME ~cdbrbrp.itm~ BEGIN   // For BG2EE
                    COPY_EXISTING ~cdbrbrp.itm~ ~override/cdbrbrp3.itm~
                    
                    
ACTION_IF FILE_EXISTS_IN_GAME ~werewlf1.itm~ BEGIN // For IWDEE
                    COPY_EXISTING ~werewlf1.itm~ ~override/werewlf3~

ACTION_IF F... plah plah plah is totally unnessasary, while you could do this by adding the COPY_EXISTING to the previous ACTION_IF GAME_IS functions insides...

 

Aka, if you aren't taking input from the player, or customizing multiple files at the same time, then there is only 1 ACTION_IF clause for the main functionality of the modification action.

Edited by Jarno Mikkola
Link to comment
37 minutes ago, Jarno Mikkola said:

ACTION_IF F... plah plah plah is totally unnessasary, while you could do this by adding the COPY_EXISTING to the previous ACTION_IF GAME_IS functions insides...

I'm not quite sure I understand.

43 minutes ago, Jarno Mikkola said:

Aka, if you aren't taking input from the player, or customizing multiple files at the same time, then there is only 1 ACTION_IF clause for the main functionality of the modification action.

ok then how do I make it so that it alters the file corresponding to the specific game without copying the same code 3 times for each instance?
 

Link to comment

Feel free to ignore Jarno in this case.

Firstly, if you want to do an "else if" (like in C-style languages), that's totally valid and common:

ACTION_IF (x) BEGIN
  // do something
END
ELSE ACTION_IF (y) BEGIN
  // do something else
END

For what you're doing, it's easiest to extract the stuff that will be different into the game-specific checks and then proceed with the shared code.  For example, you could set a variable to a specific value and then reference the variable in the shared code.

I wasn't sure I understood what you were attempting, but it looked like you were first modifying some source files, then cloning those source files and making further changes to the clones.  You could do that like so:

ACTION_IF GAME_IS ~BGEE~ BEGIN
  OUTER_TEXT_SPRINT source_paw ~brbrp~
  OUTER_TEXT_SPRINT destination_paw ~brbrp2~
END
ELSE ACTION_IF GAME_IS ~BG2EE~ BEGIN
  OUTER_TEXT_SPRINT source_paw ~cdbrbrp~
  OUTER_TEXT_SPRINT destination_paw ~cdbrbrp3~
END
ELSE ACTION_IF GAME_IS ~IWDEE~ BEGIN
  OUTER_TEXT_SPRINT source_paw ~werewlf1~
  OUTER_TEXT_SPRINT destination_paw ~werewlf3~
END

ACTION_IF FILE_EXISTS_IN_GAME ~%source_paw%.itm~ BEGIN
  COPY_EXISTING ~%source_paw%.itm~ ~override~
    LAUNCH_PATCH_FUNCTION ~ALTER_SPELL_EFFECT~ // LINKS TRANSFORMATION WITH CORRECT PAW ATTACK
      INT_VAR
        check_globals = 1
        check_headers = 1
        header = 1
        header_type = 1
        match_opcode = 111
        timing = 2
      STR_VAR 
        resource = EVAL ~%destination_paw%~
    END
    BUT_ONLY
  
  COPY_EXISTING ~%source_paw%.itm~ ~override/%destination_paw%.itm~
    LAUNCH_PATCH_FUNCTION ~ALTER_ITEM_HEADER~ // dice size and dice thrown
      INT_VAR
        check_globals = 1
        check_headers = 1
        header = 1
        header_type = 1
        dicesize  = 12
        dicenumber = 1
        damage_bonus = 0
    END
END

You may also want to add a condition to the component to prevent users from installing it on games other than the ones you support.  You can do so by adding a REQUIRE_PREDICATE right after the start of your component.  When the condition isn't met, the user will be prevented from installing the component and they will instead see the associated message.

BEGIN ~My Component~
REQUIRE_PREDICATE GAME_IS ~BGEE BG2EE IWDEE~ ~This component can only be installed on BGEE, BG2EE, and IWDEE games.~

 

Link to comment
6 minutes ago, Mike1072 said:

I wasn't sure I understood what you were attempting, but it looked like you were first modifying some source files, then cloning those source files and making further changes to the clones.

Looking at the actual resources in Near Infinity, there aren't any #111 effects on the ITM files, so you may want to be applying that ALTER_SPELL_EFFECT function on the SPL files that create the items in the first place.  But that is a separate discussion.

Link to comment
15 hours ago, Mike1072 said:

Feel free to ignore Jarno in this case.

Firstly, if you want to do an "else if" (like in C-style languages), that's totally valid and common:



ACTION_IF (x) BEGIN
  // do something
END
ELSE ACTION_IF (y) BEGIN
  // do something else
END

For what you're doing, it's easiest to extract the stuff that will be different into the game-specific checks and then proceed with the shared code.  For example, you could set a variable to a specific value and then reference the variable in the shared code.

I wasn't sure I understood what you were attempting, but it looked like you were first modifying some source files, then cloning those source files and making further changes to the clones.  You could do that like so:



ACTION_IF GAME_IS ~BGEE~ BEGIN
  OUTER_TEXT_SPRINT source_paw ~brbrp~
  OUTER_TEXT_SPRINT destination_paw ~brbrp2~
END
ELSE ACTION_IF GAME_IS ~BG2EE~ BEGIN
  OUTER_TEXT_SPRINT source_paw ~cdbrbrp~
  OUTER_TEXT_SPRINT destination_paw ~cdbrbrp3~
END
ELSE ACTION_IF GAME_IS ~IWDEE~ BEGIN
  OUTER_TEXT_SPRINT source_paw ~werewlf1~
  OUTER_TEXT_SPRINT destination_paw ~werewlf3~
END

ACTION_IF FILE_EXISTS_IN_GAME ~%source_paw%.itm~ BEGIN
  COPY_EXISTING ~%source_paw%.itm~ ~override~
    LAUNCH_PATCH_FUNCTION ~ALTER_SPELL_EFFECT~ // LINKS TRANSFORMATION WITH CORRECT PAW ATTACK
      INT_VAR
        check_globals = 1
        check_headers = 1
        header = 1
        header_type = 1
        match_opcode = 111
        timing = 2
      STR_VAR 
        resource = EVAL ~%destination_paw%~
    END
    BUT_ONLY
  
  COPY_EXISTING ~%source_paw%.itm~ ~override/%destination_paw%.itm~
    LAUNCH_PATCH_FUNCTION ~ALTER_ITEM_HEADER~ // dice size and dice thrown
      INT_VAR
        check_globals = 1
        check_headers = 1
        header = 1
        header_type = 1
        dicesize  = 12
        dicenumber = 1
        damage_bonus = 0
    END
END

You may also want to add a condition to the component to prevent users from installing it on games other than the ones you support.  You can do so by adding a REQUIRE_PREDICATE right after the start of your component.  When the condition isn't met, the user will be prevented from installing the component and they will instead see the associated message.



BEGIN ~My Component~
REQUIRE_PREDICATE GAME_IS ~BGEE BG2EE IWDEE~ ~This component can only be installed on BGEE, BG2EE, and IWDEE games.~

 

Thanks! Thats exactly what I needed! And yeah ITM doesnt have opcode 111, that part was from a different part of the code.

Although it seems to be ignoring the code now...

Basically the point of the mod is that when your using the Shapeshifter Druid kit, it adds a weaker werewolf form for lower levels ( among other changes to the kit that dont matter here). Now everytime I transform into the lesser form and try to go to inventory, stats, spellbook, etc. the game crashes. I boldened the part that causes the issue:

 

// For BG1EE
ACTION_IF GAME_IS ~BGEE~ BEGIN
  OUTER_TEXT_SPRINT source_paw ~brbrp~
  OUTER_TEXT_SPRINT destination_paw ~brbrp2~
END

 // For BG2EE
ELSE ACTION_IF GAME_IS ~BG2EE~ BEGIN
  OUTER_TEXT_SPRINT source_paw ~cdbrbrp~
  OUTER_TEXT_SPRINT destination_paw ~cdbrbrp3~
END

// For IWDEE
ELSE ACTION_IF GAME_IS ~IWDEE~ BEGIN
  OUTER_TEXT_SPRINT source_paw ~werewlf1~
  OUTER_TEXT_SPRINT destination_paw ~werewlf3~
END

    
        COPY_EXISTING ~%source_paw%.itm~ ~override/%destination_paw%.itm~

            LAUNCH_PATCH_FUNCTION ~ALTER_ITEM_EFFECT~ // LINKS TRANSFORMATION WITH CORRECT PAW ATTACK
              INT_VAR
              
              STR_VAR 
                resource = ~WERELEDR~
            END 
            

            LAUNCH_PATCH_FUNCTION ~ALTER_ITEM_HEADER~ // dice size and dice thrown
              INT_VAR
              check_globals = 1
              check_headers = 1
                header = 1
                header_type = 1
                dicesize  = 6
                dicenumber = 1
                damage_bonus = 0
            END
[......] ( similar opcode changes)

 


    
COPY_EXISTING ~spcl643.spl~ ~override/spcl645.spl~  // adds the Shapeshift: Lesser Werewolf transformation
            SAY NAME1 ~Shapeshift: Lesser Werewolf~
            SAY NAME2 ~Shapeshift: Lesser Werewolf~
            SAY 0x50 ~Shapeshift: Lesser Werewolf

                    Strength: 18 
                    Dexterity: 15
                    Constitution: 15
                    
                    Base Armor Class: 4
                    Number of Attacks: 1
                    Attack Damage: 1d6 (slashing), strikes as +1 weapon

                    Special Abilities:
                    – Magic Resistance: 10% ~
            

        LAUNCH_PATCH_FUNCTION ~ALTER_SPELL_EFFECT~ // LINKS TRANSFORMATION WITH CORRECT PAW ATTACK
              INT_VAR
                check_globals = 1
                check_headers = 1
                header = 1
                header_type = 1
                match_opcode = 111
                timing = 2
              
              STR_VAR 
                resource = ~%destination_paw%//heres the problem. For some reason, it doesn't put destination_paw. When I designate brbrp2 (the file it would need for BG1) it works. 
            END     

                    
        LAUNCH_PATCH_FUNCTION ~ALTER_SPELL_EFFECT~ // Makes polymorph cosmetic only
          INT_VAR
            match_opcode = 135                         
            timing = 0   
            target = 1          
            resistance = 2
            parameter1 = 0                                                                 
            parameter2 = 0   // 1 = Appearance only, 0 = normal morphing
            probability1 = 100                                                             
            insert_point = 0    
            
          STR_VAR 
            resource = ~WERELEDR~
    
        END
    

 

Edited by gamemaster76
Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...