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

    Joined:
    Sep 9, 2007
    Messages:
    675
    Location:
    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 CvFinalFrontierEvents.py:
    Code:
            #------------------------------ JumpPoint STARTS
            iImprovementJumpPointID = CvUtil.findInfoTypeNum(gc.getImprovementInfo,gc.getNumImprovementInfos(),'IMPROVEMENT_JUMP_POINT')
            #JumpPoint Finished
            if (iImprovement == iImprovementJumpPointID):
                pPlot = CyMap().plot(iX, iY)
                #pPlot.setImprovementType(-1)
                
                # 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:
    Code:
    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 @
    onEndGameTurn(...):
    Code:
    #JumpPoint REMOVAL STARTS
    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:
    Code:
    pUnit.setMoves(0)
    
    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 :

    Code:
    <ImprovementInfo>
                <Type>IMPROVEMENT_JUMP_POINT</Type>
                <Description>Jump Point</Description>
                <Civilopedia>TXT_KEY_IMPROVEMENT_FORT_PEDIA</Civilopedia>
                <ArtDefineTag>ART_DEF_IMPROVEMENT_JUMP_POINT</ArtDefineTag>
                <YieldChanges/>
                <bActsAsCity>1</bActsAsCity>
                <bHillsMakesValid>0</bHillsMakesValid>
                <bFreshWaterMakesValid>0</bFreshWaterMakesValid>
                <bRiverSideMakesValid>0</bRiverSideMakesValid>
                <bNoFreshWater>0</bNoFreshWater>
                <bRequiresFlatlands>0</bRequiresFlatlands>
                <bRequiresRiverSide>0</bRequiresRiverSide>
                <bRequiresIrrigation>0</bRequiresIrrigation>
                <bCarriesIrrigation>0</bCarriesIrrigation>
                <bRequiresFeature>0</bRequiresFeature>
                <bWater>0</bWater>
                <bGoody>0</bGoody>
                <bPermanent>0</bPermanent>
                <bUseLSystem>1</bUseLSystem>
                <iAdvancedStartCost>60</iAdvancedStartCost>
                <iAdvancedStartCostIncrease>0</iAdvancedStartCostIncrease>
                <iTilesPerGoody>0</iTilesPerGoody>
                <iGoodyRange>0</iGoodyRange>
                <iFeatureGrowth>0</iFeatureGrowth>
                <iUpgradeTime>0</iUpgradeTime>
                <iAirBombDefense>0</iAirBombDefense>
                <iDefenseModifier>0</iDefenseModifier>
                <iHappiness>0</iHappiness>
                <iPillageGold>0</iPillageGold>
                <bOutsideBorders>1</bOutsideBorders>
                <TerrainMakesValids>
                    <TerrainMakesValid>
                        <TerrainType>TERRAIN_GRASS</TerrainType>
                        <bMakesValid>1</bMakesValid>
                    </TerrainMakesValid>
                    <TerrainMakesValid>
                        <TerrainType>TERRAIN_PLAINS</TerrainType>
                        <bMakesValid>1</bMakesValid>
                    </TerrainMakesValid>
                    <TerrainMakesValid>
                        <TerrainType>TERRAIN_DESERT</TerrainType>
                        <bMakesValid>1</bMakesValid>
                    </TerrainMakesValid>
                    <TerrainMakesValid>
                        <TerrainType>TERRAIN_TUNDRA</TerrainType>
                        <bMakesValid>1</bMakesValid>
                    </TerrainMakesValid>
                    <TerrainMakesValid>
                        <TerrainType>TERRAIN_SNOW</TerrainType>
                        <bMakesValid>1</bMakesValid>
                    </TerrainMakesValid>
                </TerrainMakesValids>
                <FeatureMakesValids/>
                <ImprovementPillage/>
                <ImprovementUpgrade/>
                <TechYieldChanges/>
                <RouteYieldChanges/>
                <bGraphicalOnly>0</bGraphicalOnly>
            </ImprovementInfo>
    


    And the XML for the BuildInfo:
    Spoiler :

    Code:
    <BuildInfo>
                <Type>BUILD_JUMP_POINT</Type>
                <Description>Open JumpPoint</Description>
                <Help/>
                <PrereqTech>NONE</PrereqTech>
                <iTime>0</iTime>
                <iCost>0</iCost>
                <bKill>0</bKill>
                <ImprovementType>IMPROVEMENT_JUMP_POINT</ImprovementType>
                <RouteType>NONE</RouteType>
                <EntityEvent>ENTITY_EVENT_BUILD</EntityEvent>
                <FeatureStructs/>
                <HotKey>KB_F</HotKey>
                <bAltDown>0</bAltDown>
                <bShiftDown>0</bShiftDown>
                <bCtrlDown>1</bCtrlDown>
                <iHotKeyPriority>0</iHotKeyPriority>
                <Button>Art/Interface/Buttons/OpenJumpPointButton.dds</Button>
            </BuildInfo>
    


    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