Help, fighting "worker" mechanics in FF

Discussion in 'Civ4 - SDK/Python' started by Premier Valle, May 13, 2008.

  1. Premier Valle

    Premier Valle FF: Babylon 5 Mod Team

    Sep 9, 2007
    Ich bin in Mexico Stadt
    Hello everyone!

    I'm in a mod team,we are making a mod based on the Final Frontier mod, here is what I want to do:

    A ship can open a Jump Point (JP) in the space, and make a "jump" from there to somewhere else, other friendly ships can jump from the same JP.

    The algorithm:
    - A ship can BUILD a Jump Point IMPROVEMENT
    - Once the JP Improvement is built ships can PARADROP from it to somewhere else.
    - The JP Improvement is like a modified fort, and in order for a unit to paradrop from it, the JP improvement must have culture.
    - The JP Improvement is removed at the next turn

    Here is the code I'm using to give culture to the JP Improvement @ onImprovementBuilt(...) in
            #------------------------------ JumpPoint STARTS
            iImprovementJumpPointID = CvUtil.findInfoTypeNum(gc.getImprovementInfo,gc.getNumImprovementInfos(),'IMPROVEMENT_JUMP_POINT')
            #JumpPoint Finished
            if (iImprovement == iImprovementJumpPointID):
                pPlot = CyMap().plot(iX, iY)
                # Look for the jumping Ship on this plot
                for iUnitLoop in range(pPlot.getNumUnits()):
                    pUnit = pPlot.getUnit(iUnitLoop)
                    pUnit.setName("Da unit")
                    pUnit.setMoves(0)    #Resets the movement points for every other ship (so they can jump)
    #                if (pUnit.getScriptData() == "BuildingJumpPoint"):    #THIS CODE IS USELESS SINCE THE SCRIPT IS NEVER SET
                        #self.doMakeStarbase(pUnit.getOwner(), iX, iY)
                        #self.aiKillTimerData = [3, pUnit.getOwner(), pUnit.getID()]
    #                    szTitle = self.szGameDate = CyGameTextMgr().getTimeStr(CyGame().getGameTurn(), false)
    #                    popup = PyPopup.PyPopup(-1)
    #                    popup.setHeaderString(szTitle)
    #                    popup.setBodyString('pUnit!')
    #                    popup.launch(true, PopupStates.POPUPSTATE_QUEUED)
                self.jumpPointCulture(pUnit.getOwner(), iX, iY)
            #------------------------------ JumpPoint ENDS
    Here is the code that actually creates the culture for the JP improvement:
    def jumpPointCulture(self, iPlayer, iX, iY):
            #Create culture at the jump point location, so that ships can jump from there
            #Based on the updateStarbaseCulture(...)
            iActiveX = iX#iXLoop
            iActiveY = iY#iYLoop
            if (iActiveX < 0):
                iActiveX = CyMap().getGridWidth() + iActiveX
            if (iActiveY < 0):
                iActiveY = CyMap().getGridHeight() + iActiveY
            pLoopPlot = CyMap().plot(iActiveX, iActiveY)    #GETS THE PLOT IN THIS COORDINATE
            # Don't override culture that's already here
            if (pLoopPlot.getOwner() == -1):                #DOES THE PLOT BELONG TO SOMEONE?
                pLoopPlot.setOwner(iPlayer)                    #SET THE PLOT'S CULTURE
            #jumpPointCulture() END

    And just in case, here is the code that removes the JP improvement @
    b5_totalMapPlots = CyMap().numPlots()    #Total number of plots in the map
            b5_count = 0
            while b5_count != b5_totalMapPlots:        #For-Each plot in the map
                b5_plot = CyMap().plotByIndex(b5_count)        #get a tile of the map by index
                if (b5_plot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_JUMP_POINT')): #if the improvement is a jump point
                    b5_plot.setImprovementType(-1)    #remove the jump point improvement
                b5_count = b5_count + 1
            #JumpPoint REMOVAL ENDS

    The problem here is that when a ship builds a JP improvement it looses all movement points, and hence can't make the "jump", even with this line:
    All units in the same plot/tile/square regain all their movement points, except the unit that built the JP improvement.

    The JP improvement XML:
    Spoiler :

                <Description>Jump Point</Description>

    And the XML for the BuildInfo:
    Spoiler :

                <Description>Open JumpPoint</Description>

    Any idea as to how make the unit that builds the JP improvement able to make the jump??

    Any help will be appretiated :beer:

Share This Page