Is it possible to lock a new technology like the Lanun?

Discussion in 'Civ4 - Fall from Heaven' started by Chiyo-chan, Oct 20, 2020.

  1. Chiyo-chan

    Chiyo-chan Chieftain

    Joined:
    Jul 18, 2010
    Messages:
    7
    I have tried adding some new tech's to the game, i wanted a few new ones which would be restricted to a new civ i am working on, but i am having troubles keeping the tech locked. The Lanun have "Sea Faring" which cannot be researched by anyone (and they start with it), this is essentially what i am trying to achieve. I tried making a similar copy of Sea Faring to work from but nothing is working. I was hoping simply setting the <icost> values to -1 would work but this just sets the ingame research cost to 1.

    I am not good with Python but looked into it a little, i found a bit of code:
    Code:
            if eTech == gc.getInfoTypeForString('TECH_SEAFARING'):
                if iCiv != gc.getInfoTypeForString('CIVILIZATION_LANUN'):
                    return True
            if pPlayer.isHuman() == False:
    Now as said i am not good at Python, honestly i don't get most of it. To my understand though this is possibly the code i need to add to my tech, which i tried doing like so;

    Code:
            if eTech == gc.getInfoTypeForString('TECH_
    Otherworldly_Presence
    '):
                if iCiv != gc.getInfoTypeForString('CIVILIZATION_LANUN'):
                    return True
            if pPlayer.isHuman() == False:
    I haven't made the civ yet who will use it but tested this on both current civs (Lanun, both Elven leaders, Banor ect) and it seems to just remove the UI in game. not quite sure what i am missing.

    I have created a entry in the XML which adds the tech to the tech tree which works fine, i have added definition values to let the game read it's name and such in game in the gametext files too. I figured adding this line of Python would do the trick but it didn't.

    Does anyone know
    1 - what i am doing wrong or missing?
    2 - why when i add the additional line of python does it break my games interface and doesn't let me do much more than move units (can't settle cities or anything). I figure this might be my ignorance though. I can confirm this is associated with the above code as when i remove my added bit, everything works as it should.

    Any help on this would be appreciated, as mentioned Python is something i am not good with, i am currently reading some tutorials to get the hang of it but most of these are based on the OG civ games and not FFH mods so whilst i don't get the old stuff, the one ones throw me completely.
    I only in theory need this initial starting tech to work in a similar way to Sea Faring, once i have this one i can simply hitch of it with further follow up tech's by making this a pre-required tech.

    Also - is it possible to make techs require a certain building to research them? I figure this would be a alt way around the issue if i could change the tech to require xxx Palace to research, as only the respective civ would have their own palace and thus restrict access.

    Thanks for anyone who takes the time to read this.
     
    Last edited: Oct 23, 2020
  2. lfgr

    lfgr King

    Joined:
    Feb 6, 2010
    Messages:
    965
    You likely have a syntax error in your python code. Do you have python exception popups enabled (see guide)? What (python) changes exactly did you make?
     
  3. Chiyo-chan

    Chiyo-chan Chieftain

    Joined:
    Jul 18, 2010
    Messages:
    7
    Hi, thanks for the reply.

    I enabled the exceptions popups though these began to flood me with many notices across numerous files (though some of which was blank).
    My change was limited, most pythons changes i made have worked in just filling in extra lines by copying a older code line into the new position, of course as mentioned i know this isn't ideal, i am still learning python sadly.

    Here was the before and after code:
    Previous code:
    Code:
            if eTech == gc.getInfoTypeForString('TECH_SEAFARING'):
                if iCiv != gc.getInfoTypeForString('CIVILIZATION_LANUN'):
                    return True
            if pPlayer.isHuman() == False:
                          
    
                if eTech == gc.getInfoTypeForString('TECH_STIRRUPS'):
                    if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CLAN_OF_EMBERS'):
                        return True
                    if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
                        return True
                  
    
    New Code:
    Code:
            if eTech == gc.getInfoTypeForString('TECH_SEAFARING'):
                if iCiv != gc.getInfoTypeForString('CIVILIZATION_LANUN'):
                    return True
            if pPlayer.isHuman() == False:
                          
    
                    if eTech == gc.getInfoTypeForString('TECH_Otherworldly_Presence'):
                if iCiv != gc.getInfoTypeForString('CIVILIZATION_Asukara'):
                    return True
            if pPlayer.isHuman() == False:
                  
    
     
                if eTech == gc.getInfoTypeForString('TECH_STIRRUPS'):
                    if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CLAN_OF_EMBERS'):
                        return True
                    if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
                        return True
                  
    
    (The middle section being the new code)
    It did highlight a error upon starting in the line the code was added to but the error was blank so i could figure anything from it.

    It did however highlight line 249 which is the blank line above where i added my code being the problem: (as below)

    I presume this is a more detailed matter of just inserting code as i have done with other instances.
     
  4. black_imperator

    black_imperator Emperor

    Joined:
    Dec 4, 2005
    Messages:
    1,819
    ok, it's relatively simple.
    First things first, the line "if pPlayer.isHuman() == False:" is not part of the code for the tech ( either the one for Seafaring or the one for your new tech), it's part of the following block.

    Second thing, which causes your main error is that python requires specific code structure. In particular, the various lines of code need to be properly aligned :

    Code:
     
            if eTech == gc.getInfoTypeForString('TECH_SEAFARING'):
                if iCiv != gc.getInfoTypeForString('CIVILIZATION_LANUN'):
                    return True
            if eTech == gc.getInfoTypeForString('TECH_Otherworldly_Presence'):
                if iCiv != gc.getInfoTypeForString('CIVILIZATION_Asukara'):
                    return True
            
            if pPlayer.isHuman() == False:
                if eTech == gc.getInfoTypeForString('TECH_STIRRUPS'):
                    if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CLAN_OF_EMBERS'):
                        return True
                    if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
                        return True
    This organization should clear your issue
     
    Chiyo-chan and lfgr like this.
  5. Chiyo-chan

    Chiyo-chan Chieftain

    Joined:
    Jul 18, 2010
    Messages:
    7
    As thank you for this. I admit the "if pPlayer.isHuman() == False:" line confused me as i didn't think it belonged, i actually couldn't make sense of how it fit the code at all so was of course a bit thrown by the idea of it being present, but i saw it there so figured it did something, guess i was pretty stupid not to try removing it hehe.

    But thanks for this, i tried the above and it fixed the issues, i also tried it was several other techs for some practise, the python stuff takes some learning but i am slowly getting the hang of some it now now.

    Thank you again for the help, i am trying to learn from any mistake so only post here when it begins to get to me, so it's very much appreciated :)
     
  6. Calavente

    Calavente Richard's voice

    Joined:
    Jun 4, 2006
    Messages:
    2,864
    Location:
    France
    aren't most of those triggered as requiring the "Never" tech as prerequist (thus never tech-able) and being hardcoded "granted" to a civ, like most civs have different starting techs.??
     

Share This Page