How to "unlearn" technology?

Crayton

King
Joined
Jul 18, 2004
Messages
698
Location
FLORIDA
I have been looking for a way to remove a civ's research of a technology. I have been able to change a known technology into one that is unknown, but the research is already at 100% and the tech can be acquired the next turn.

Is there any way to remove the actual research a civ has for a particular technology, to return research to 0%? My ultimate goal is to engineer some kind of "eternal" game; but, this is a step I must first learn how to take.

Please and Thank You.
 
I used a funtion from CvTeam setResearchProgress in my spy mod to cause setbacks in a teams research, you could easily use it to set their research back to zero and prevent them from imediatly re-poping the tech. Civ4 realy "should" reset this number after you aquire the tech

Are you planning some kind of "Dark Age" which which civs will regress, loose tech and probably cities/infastructure, it definantly sounds interesting and would be neat to combine with jdog5000's revolution mod in which new empires are able to be spontaniously generated (idealy durring the times someone else is in decline or even as a result of). The game would proceed as a cycle of advance and retreat, rise and fall, two steps forward, one step back. It would also give balance to the core game, now Tech is quote "The ALL" amongst hard core players meaning it is the desiding factor in winning or lossing. One of the main reasons is that of all the things you can get/have in Civ Tech is the only one which could never be taken away. By being able to loose tech the players strategy would change considirably (assuming ofcorse that these tech losses disporoportionatly hit the tech leader, otherwise they would reinforce the current strategy).
 
The way the function currently exists is as follows

iForgottenTech = gc.getGame().getSorenRandNum(gc.getNumTechInfos(), 'tech index')

for iCiv in range(18):
[TAB]gc.getTeam(gc.getPlayer(iCiv).getTeam()).setHasTech(iForgottenTech, False, iCiv, False, False)

I have found the function "getResearchCommerce(self):" did you program your own function "setResearchCommerce(self, researchPercent)" or something like that? Is setResearchProgress a function that I can now call? I have thought to program a function on my own but feel like I might be playing with fire.

The code, as it is now, selects a random technology and takes it away from everyplayer. The technology is selected out of every single one on the tree, therefore tech progression slows the further you go along the tree. I believe a "2 steps forward, 1 step back" would be more in line with my original intention.
 
Well to start off with I created 2 new functions in CvTeam (its realy a piece of cake to add new functions, I do it all the time, its cleaner/easier then making a bunch of little changes in other functions and you can often re-use them (or give them to other people :D )

The function your using seems kind of crude, your not doing any checking to see if they HAVE the tech being taken away, its just getting any random tech in the whole game. Inorder to be belivable your going to need to focus the effect on the players relitivly resent techs. When a civilization goes into a dark age it the relitivly cutting edge "high" knowlage which is lost, so for example after the fall of Rome, Liturature, Architecture, Philosopy and other such techs are "lost" not things like the wheel or Bronze Working. I'd sugjest you create functions to select these types of techs.

Below are 2 of the functions in my Spy mod. The first one getRandomStealableTech randomly selects a tech that the calling Team (A) could steal from the argument team (B) , this means that either A lacks in and B has it or B simply is ahead of A in researchprogress (on a percetial basis), I hard coded a minimum of 10% greater progress so you wouldn't get situations ware you steal a measly 3 research points. The second function is rather self explamitory, I use it to normalize the AI's progress relitive to the Players as the AI gets its techs for less points depending on the games difficulty.


Code:
int CvTeam::getRandomStealableTech(TeamTypes eTeam)
{
    bool* pbTechs = new bool[GC.getNumTechInfos()];
    int i;
    int counter = 0;
    CvWString sTech;

    for(i = 0; i < GC.getNumTechInfos(); i++)
    {
        if (!isHasTech((TechTypes) i))
        {
            if(GET_TEAM(eTeam).isHasTech((TechTypes) i))
            {
                if (true /*canStealTech((TechTypes) i)*/ ) // option for additional checking function
                {
                    pbTechs[i] = true;
                    counter++;
                    continue;
                }
            }

            if(getPercentResearchProgress((TechTypes) i) + 10 < GET_TEAM(eTeam).getPercentResearchProgress((TechTypes) i))
            {
                pbTechs[i] = true;
                counter++;
                continue;
            }
            pbTechs[i] = false;
        }
        pbTechs[i] = false;
    }

    if (counter == 0)
    {
        SAFE_DELETE_ARRAY(pbTechs);
        logMsg("Returning NO_TECH");
        return NO_TECH;
    }

    counter = GC.getGameINLINE().getSorenRandNum(counter, "Random Stealable Tech");

    for (i = 0; i < GC.getNumTechInfos(); i++)
    {
        if (pbTechs[i])
        {
            if (counter == 0)
            {
                SAFE_DELETE_ARRAY(pbTechs);
                return i;
            }
            counter--;
        }
    }

    SAFE_DELETE_ARRAY(pbTechs);
    return NO_TECH;
}

int CvTeam::getPercentResearchProgress(TechTypes eTech) const
{
    if (isHasTech((TechTypes) eTech))
    {
        return 100;
    }

    return (getResearchProgress((TechTypes) eTech) * 100 / getResearchCost((TechTypes) eTech)) ;
}

void CvTeam::setResearchProgress(TechTypes eIndex, int iNewValue, PlayerTypes ePlayer)

Is an existing function by Firaxis, its normaly called each turn to roll the players research into their current tech goal, it then checks if your in excess of the tech cost and if so gives the tech by setting the hasTech boolean and giving you overflow. After its given a player a tech it dosn't do anything with the progress resulting in imidate re-aquisition next turn.

If you do this you should be able to wipe out the tech completly with the folowing 2 Python calls or if you want to get into the sourcecode and do something their as well that would also work, depends on what your more comfortable with (but I recomend working in the SDK because of its greater power)

Code:
gc.getTeam(gc.getPlayer(iCiv).getTeam()).setHasTec h(iForgottenTech, False, iCiv, False, False)

gc.getTeam(gc.getPlayer(iCiv).getTeam()).changeResearchProgress(iForgottenTech, 0, iCiv)
 
Well I got it to work. I used setResearchProgress . The general effect to the game was excellent. When one civ expanded too quickly not only did it's economy fail but so did it's technology; leaving behind only a few advanced units.

But I do need to work on the implementation. After researching an advanced tech or two, I had to spend around 5 turns re-acquiring ancient technology. By the year 2050 I had finally entered the Industrial Age, so I will have to scour this site for the prime conditions of losing a tech. Any suggestions are welcome.

Besides the constant re-researching the general flow of technology was much more agreeable than in vanilla civ, perhaps only because I watched the #1 civ experience a dark age and "fall." My next steps will be rescaling the speed of the game and adding later barbarians. Wish me luck.
 
Top Bottom