1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Cities acting like units!

Discussion in 'Civ4 - SDK/Python' started by Civkid1991, Aug 7, 2006.

  1. Gerikes

    Gerikes User of Run-on Sentences.

    Joined:
    Jul 26, 2005
    Messages:
    1,753
    Location:
    Massachusetts

    If you want to save things to a specific plot, I'd suggest you take a look at sdToolkit.

    http://forums.civfanatics.com/showthread.php?t=146130&highlight=sdToolkit

    It allows you to save values to specific plots, so you don't need to make a huge data structure to save all the individual plot values in.

    Not sure how the fuel would work exactly, but I would imagine you would be having a limited amount on each plot that the city uses up when it moves onto/off of it? If so, sdToolkit is probably your best bet. If you need fuel to be "regained", you'd probably do something so that at the end of each turn, you go to every plot and add a bit to that plot's amount.

    The sdToolkit allows you to store all that into the plot's script data, meaning it will be stored with game saves as well. And, it allows you to add information to plots / units / cities etc. without having to do anything in the SDK.
     
  2. Civkid1991

    Civkid1991 in shade of poison trees

    Joined:
    Feb 20, 2006
    Messages:
    871
    Cool thanks:goodjob: ... this would be helpfull. (It works for gp points, commerce, gold, an stuff like that too right?)
     
  3. Gerikes

    Gerikes User of Run-on Sentences.

    Joined:
    Jul 26, 2005
    Messages:
    1,753
    Location:
    Massachusetts
    Well, the idea isn't that it changes stuff already in the game, rather it allows you to add new items. If you want to change how the stuff in the game already works, you'll probably need to be editting the SDK.
     
  4. Civkid1991

    Civkid1991 in shade of poison trees

    Joined:
    Feb 20, 2006
    Messages:
    871
    Hmmm... maybe i misunderstude what you where saying... sd toolkit saves the plot location and other data into a file for the game. An as long as they're predefined in the sdk (i think) then i can save the values and then recall them after the city is destroyed...
     
  5. Gerikes

    Gerikes User of Run-on Sentences.

    Joined:
    Jul 26, 2005
    Messages:
    1,753
    Location:
    Massachusetts
    Yup, you do misunderstand me :p


    For each unit, city, and plot, there is a variable called the script data. This is just a string that is supposed to be used for people who want to put some sort of data into the unit, but don't want to mod the SDK.

    What sdToolkit does is allows you to easily create multiple different kinds of data variables, then it converts those into strings and places them into the script data. It has nothing to do with any of the pre-existing data of the plot (the X, Y, improvements, etc.). It allows you to store new data that you are making up.

    Say you are using it on a plot to store how many fuel "resources" there are there. At the beginning of the game you can go to each plot and add to it an integer variable for how many resources are there by default. Then, perhaps every turn, you go to every plot, and just change this value.

    You're not changing anything to do with the normal values that the plot object contains, you're just making your own piece of data that stays attached to that plot.

    If you were to make data and attach it to a city, it stays with the city object. If the city is destroyed, then the data is destroyed.

    The other way of doing what the toolkit allows you to do is:

    1.) Modify the sdk and make new variables for each new piece of data you want to add to the city (or plot, or unit, etc.), or
    2.) Make a whole new data type in python and have it store all the values for all the plot (unit, city...) within it (probably a dictionary). Whenever you want the value, you search the dictionary for your object (iX and iY value for a plot would probably be the key).
     
  6. Civkid1991

    Civkid1991 in shade of poison trees

    Joined:
    Feb 20, 2006
    Messages:
    871
    Ok... i understand.

    I'll probably end up using the sd toolkit for the fuel and then a dictionary for the data saving...

    Code:
    
    def SaveCityData(data):
           cityData = {
                 FUEL_AMOUNT   : fuel,
                 CITY_BUILDINGS: buildings,
                 CITY_PRODUCTION: Production
                 ...
            }
    ...
    
    
    Something similar to that (that was psudo-code) ill just define the function add call it to save the data in an dictionary... then kill the city... then reload the data.
     
  7. Civkid1991

    Civkid1991 in shade of poison trees

    Joined:
    Feb 20, 2006
    Messages:
    871
    first post has been updated...
     
  8. thomas.berubeg

    thomas.berubeg Wandering the World

    Joined:
    Aug 21, 2006
    Messages:
    9,037
    Location:
    Ft. Lauderdale
    are you going to have the "doomsday" weapons? (Odin, Medusa, maybe invent a few)
     
  9. Civkid1991

    Civkid1991 in shade of poison trees

    Joined:
    Feb 20, 2006
    Messages:
    871
    well i was thinking about it and ill deside in the later version... but for the first release im going to say no..

    Im thinking of doing a scenario for the mod to that would be semi-Rpg-ish that would follow the story... it may include medusa. But for right now im still thinking about it.
     
  10. Civkid1991

    Civkid1991 in shade of poison trees

    Joined:
    Feb 20, 2006
    Messages:
    871
    @Gerikes

    I played your mod over the week end and i thought it was really helpful. I need to dl the source (have you released it yet?) and then see how it works. I like how you added in mineral, gas, and pop as a resource (?). And i also like the way you changed combate... that would also be helpful with city combat.:goodjob: Great Job :)
     
  11. Civkid1991

    Civkid1991 in shade of poison trees

    Joined:
    Feb 20, 2006
    Messages:
    871
    New graphics by Chamaedrys. Includes the traction city and the airship :D
     
  12. matteo773

    matteo773 Deity

    Joined:
    Jul 10, 2005
    Messages:
    102
    Location:
    England
    You must tell me if I can help, I wanted to start this mod a couple of months back but there was no interest. Unfortunately I lack in civ 4 modding skills (something I hope to change soon) but I've got lots of ideas if you need any.
     
  13. Civkid1991

    Civkid1991 in shade of poison trees

    Joined:
    Feb 20, 2006
    Messages:
    871
    cool... i've been really bussy currently so i have a small bit of time every week after homework to program. It would be nice if you could do a bit of reseach on some of the cities and pm/email them to me along with any ideas you may have (actually ideas would be good for the forum :) ).

    Look at my sig for the link to the python tutorial and im sure you could find a lot of stuff on other modding stuff at the civ4/civ4mod wiki.

    ps. sorry for answering so late -> my internet was down for a bit :(
     
  14. matteo773

    matteo773 Deity

    Joined:
    Jul 10, 2005
    Messages:
    102
    Location:
    England
    Well research I can do :) and I'm certainly not short on ideas ;). But I feel some of them would change your mod too much ( I was planning on setting the story in the anti-tractionist - tractionist war :sad: ). So I'll suggest some of my more realistic and useful ideas:).

    And as for the modding I could learn but I wouldn't hold your breath; as I'm certainly not a programmer:rolleyes:.

    PS. Sorry for my late reply, the amounts of homework I've been getting recently is a joke.
     
  15. Civkid1991

    Civkid1991 in shade of poison trees

    Joined:
    Feb 20, 2006
    Messages:
    871
    Cool that would be helpfull...

    programming isn't really as hard as it seems... its learning how to use the sdk, thats not as easy. But once you learn it then you should be able to easily mod the code. If your doing stuff with python its even more easier. look at my sig for a good tutorial for python.

    sorry for what reply??? :hmm:

    BTW... im going to update the first page today with the new city graphics :)
     
  16. Psycadelic_Magi

    Psycadelic_Magi Hippie/Philosopher/Peanut

    Joined:
    Apr 13, 2006
    Messages:
    237
    Location:
    Northeast England
    London is not the only english city!
    Manchester, Brighton, Grimsby, Wolverinehampton (wolverhampton) and Tunbridge wheels (tunbridge wells) are all places in england


    By the way, Manchester is supposed to be the biggest traction city in the world
     
  17. Civkid1991

    Civkid1991 in shade of poison trees

    Joined:
    Feb 20, 2006
    Messages:
    871
    O yea... i know that know. After i did a bit of research (like not enough to do any stories or anything) i found out some of the nationalities of the cities.

    Most are english and german but there is one egytian, one islandic, and one (or maybe it was two) from russia.

    I don't think im goin do the traction suburbs...
     
  18. Civkid1991

    Civkid1991 in shade of poison trees

    Joined:
    Feb 20, 2006
    Messages:
    871
    ok i have time to do a bit of modding at the moment and i think i need help with some of the xml:
    Code:
    <UnitArtInfo>
    			<Type>ART_DEF_UNIT_CITY_TRACTION</Type>
    			<fScale>0.8</fScale>
    			<fInterfaceScale>1.0</fInterfaceScale>
    			<NIF>Art/Units/tractioncity_land/traction_city.nif</NIF>
    			<KFM>Art/Units/tractioncity_land/ </KFM> <!-- what do i put here? -->
    			<SHADERNIF>Art/Units/Explorer/Explorer_FX.nif</SHADERNIF> 
    			<ShadowDef>
    				<ShadowNIF>Art/Units/01_UnitShadows/UnitShadow.nif</ShadowNIF>
    				<ShadowAttachNode>BIP Pelvis</ShadowAttachNode>
    				<fShadowScale>1.0</fShadowScale>
    			</ShadowDef>
    			<fBattleDistance>0.35</fBattleDistance>
    			<fRangedDeathTime>0.31</fRangedDeathTime>
    			<bActAsRanged>0</bActAsRanged>
    			<TrainSound>AS2D_UNIT_BUILD_UNIT</TrainSound>
    			<AudioRunSounds>
    				<AudioRunTypeLoop/>
    				<AudioRunTypeEnd/>
    			</AudioRunSounds>
    		</UnitArtInfo>
    I copyed the explore art difine and was editing it so it would be the traction city art... but i don't know what most of these do. For the art i have 1 nif files, 9 TGA files, and 1 blender file. I don't know where to put these too.
     
  19. Chamaedrys

    Chamaedrys Emperor

    Joined:
    Mar 14, 2006
    Messages:
    1,267
    Location:
    Germany
    A blender file? Oops! You wont need it.:blush:

    I sugguest to copy the entry of the mech. Inf. cause I compare and animate my model with that file, so you'll have to make less changes here.

    The fscale determins the size of the unit in the game.
    The finterfacescale the size in the civilopedia. I think it could be reduced a bit.

    the <NIF> and <SHADERNIF> tag should point to the .nif file.

    this looks good:
    The <KFM> tag should point at the .kfm file (animations) of the unit. The traction city uses Mech. Inf. animations. If you have copied the entry of the mech. Inf, it can stay as it is, otherwise copy n paste this tag from the mech inf. entry.;)

    The .tga files store the texture of the unit. Keep them in the same folder as the .nif file. DON'T RENAME THE TGA.

    happy modding

    Chamaedrys:D
     
  20. Civkid1991

    Civkid1991 in shade of poison trees

    Joined:
    Feb 20, 2006
    Messages:
    871
    ok i finaly tried what you said above today and i got these errors:

    Trackback(most resent call last)

    file ' CvScreensInterface', line 520, in leftMouseDown
    File 'CvWorldBuilderScreen', line 221, in leftMouseDown
    File 'cvWorldBuilderScreen', line 507, in placeObject

    RuntimeError unidentifiable C++ exeption

    Heres the code i put in the xml for the units:

    Spoiler CIV4UnitInfos.xm. :

    Code:
    		<UnitInfo>
    			<Class>UNITCLASS_TRACTION_CITY</Class>
    			<Type>UNIT_TRACTION_CITY</Type>
    			<UniqueNames></UniqueNames>
    			<Special>NONE</Special>
    			<Capture>NONE</Capture>
    			<Combat>UNITCOMBAT_ARMOR</Combat>
    			<Domain>DOMAIN_LAND</Domain>
    			<DefaultUnitAI>UNITAI_ATTACK</DefaultUnitAI>
    			<Invisible>NONE</Invisible>
    			<SeeInvisible>NONE</SeeInvisible>
    			<Description>TXT_KEY_UNIT_GREAT_ENGINEER</Description>
    			<Civilopedia>TXT_KEY_CONCEPT_GREAT_PEOPLE_PEDIA</Civilopedia>
    			<Strategy>TXT_KEY_UNIT_GREAT_ENGINEER_STRATEGY</Strategy>
    			<Advisor>ADVISOR_GROWTH</Advisor>
    			<bAnimal>0</bAnimal>
    			<bFood>0</bFood>
    			<bNoBadGoodies>0</bNoBadGoodies>
    			<bOnlyDefensive>0</bOnlyDefensive>
    			<bNoCapture>0</bNoCapture>
    			<bRivalTerritory>0</bRivalTerritory>
    			<bMilitaryHappiness>0</bMilitaryHappiness>
    			<bMilitarySupport>0</bMilitarySupport>
    			<bMilitaryProduction>0</bMilitaryProduction>
    			<bPillage>0</bPillage>
    			<bSabotage>0</bSabotage>
    			<bDestroy>0</bDestroy>
    			<bStealPlans>0</bStealPlans>
    			<bInvestigate>0</bInvestigate>
    			<bCounterSpy>0</bCounterSpy>
    			<bFound>0</bFound>
    			<bGoldenAge>1</bGoldenAge>
    			<bInvisible>0</bInvisible>
    			<bFirstStrikeImmune>0</bFirstStrikeImmune>
    			<bNoDefensiveBonus>0</bNoDefensiveBonus>
    			<bIgnoreBuildingDefense>0</bIgnoreBuildingDefense>
    			<bCanMoveImpassable>0</bCanMoveImpassable>
    			<bFlatMovementCost>0</bFlatMovementCost>
    			<bIgnoreTerrainCost>0</bIgnoreTerrainCost>
    			<bNukeImmune>0</bNukeImmune>
    			<bPrereqBonuses>0</bPrereqBonuses>
    			<bPrereqReligion>0</bPrereqReligion>
    			<bMechanized>0</bMechanized>
    			<UnitClassUpgrades/>
    			<UnitAIs></UnitAIs>
    			<NotUnitAIs/>
    			<Builds/>
    			<ReligionSpreads/>
    			<GreatPeoples></GreatPeoples>
    			<Buildings/>
    			<ForceBuildings/>
    			<HolyCity>NONE</HolyCity>
    			<ReligionType>NONE</ReligionType>
    			<StateReligion>NONE</StateReligion>
    			<PrereqReligion>NONE</PrereqReligion>
    			<PrereqBuilding>NONE</PrereqBuilding>
    			<PrereqTech>NONE</PrereqTech>
    			<TechTypes/>
    			<BonusType>NONE</BonusType>
    			<PrereqBonuses/>
    			<ProductionTraits/>
    			<Flavors></Flavors>
    			<iAIWeight>0</iAIWeight>
    			<iCost>-1</iCost>
    			<iHurryCostModifier>0</iHurryCostModifier>
    			<iMinAreaSize>-1</iMinAreaSize>
    			<iMoves>2</iMoves>
    			<iAirRange>0</iAirRange>
    			<iNukeRange>-1</iNukeRange>
    			<iWorkRate>0</iWorkRate>
    			<iBaseDiscover>1000</iBaseDiscover>
    			<iDiscoverMultiplier>2</iDiscoverMultiplier>
    			<iBaseHurry>500</iBaseHurry>
    			<iHurryMultiplier>20</iHurryMultiplier>
    			<iBaseTrade>0</iBaseTrade>
    			<iTradeMultiplier>0</iTradeMultiplier>
    			<iGreatWorkCulture>0</iGreatWorkCulture>
    			<TerrainImpassables/>
    			<FeatureImpassables/>
    			<iCombat>0</iCombat>
    			<iAirCombat>0</iAirCombat>
    			<iAirCombatLimit>0</iAirCombatLimit>
    			<iXPValueAttack>0</iXPValueAttack>
    			<iXPValueDefense>0</iXPValueDefense>
    			<iFirstStrikes>0</iFirstStrikes>
    			<iChanceFirstStrikes>0</iChanceFirstStrikes>
    			<iInterceptionProbability>0</iInterceptionProbability>
    			<iEvasionProbability>0</iEvasionProbability>
    			<iWithdrawalProb>0</iWithdrawalProb>
    			<iCollateralDamage>0</iCollateralDamage>
    			<iCollateralDamageLimit>0</iCollateralDamageLimit>
    			<iCollateralDamageMaxUnits>0</iCollateralDamageMaxUnits>
    			<iCityAttack>0</iCityAttack>
    			<iCityDefense>0</iCityDefense>
    			<iAnimalCombat>0</iAnimalCombat>
    			<iHillsDefense>0</iHillsDefense>
    			<TerrainNatives/>
    			<FeatureNatives/>
    			<TerrainDefenses/>
    			<FeatureDefenses/>
    			<UnitClassAttackMods/>
    			<UnitClassDefenseMods/>
    			<UnitCombatMods/>
    			<DomainMods/>
    			<BonusProductionModifiers/>
    			<iBombRate>0</iBombRate>
    			<iBombardRate>0</iBombardRate>
    			<SpecialCargo>NONE</SpecialCargo>
    			<DomainCargo>NONE</DomainCargo>
    			<iCargo>0</iCargo>
    			<iConscription>0</iConscription>
    			<iCultureGarrison>0</iCultureGarrison>
    			<iExtraCost>0</iExtraCost>
    			<iAsset>1</iAsset>
    			<iPower>0</iPower>
    			<UnitMeshGroups>
    				<iGroupSize>1</iGroupSize>
    				<fMaxSpeed>1.25</fMaxSpeed>
    				<iMeleeWaveSize>1</iMeleeWaveSize>
    				<iRangedWaveSize>1</iRangedWaveSize>
    				<UnitMeshGroup>
    					<iRequired>1</iRequired>
    					<EarlyArtDefineTag>ART_DEF_UNIT_TRACTIONCITY</EarlyArtDefineTag>
    				</UnitMeshGroup>
    			</UnitMeshGroups>
    			<Button>,Art/Interface/Buttons/Units/GreatEngineer.dds,Art/Interface/Buttons/Unit_Resource_Atlas.dds,2,8</Button>
    			<HotKey/>
    			<bAltDown>0</bAltDown>
    			<bShiftDown>0</bShiftDown>
    			<bCtrlDown>0</bCtrlDown>
    			<iHotKeyPriority>0</iHotKeyPriority>
    			<FreePromotions/>
    		</UnitInfo>
    

    Spoiler CIV4ArtDefines_Units.xml :

    Code:
    <UnitArtInfo>
    			<Type>ART_DEF_UNIT_TRACTION_CITY</Type>
    			<fScale>0.8</fScale>
    			<fInterfaceScale>1.0</fInterfaceScale>
    			<NIF>Art/Units/Traction_City/traction_city.nif</NIF>
    			<KFM>Art/Units/MechanizedInfantry/MechanizedInfantry.kfm</KFM>
    			<SHADERNIF>Art/Units/Traction_City/traction_city.nif</SHADERNIF>
    			<ShadowDef>
    				<ShadowNIF>Art/Units/01_UnitShadows/UnitShadow.nif</ShadowNIF>
    				<ShadowAttachNode>BIP Pelvis</ShadowAttachNode>
    				<fShadowScale>0.9</fShadowScale>
    			</ShadowDef>
    			<fBattleDistance>0.35</fBattleDistance>
    			<fRangedDeathTime>0.31</fRangedDeathTime>
    			<bActAsRanged>0</bActAsRanged>
    			<TrainSound>AS2D_UNIT_BUILD_UNIT</TrainSound>
    			<AudioRunSounds>
    				<AudioRunTypeLoop/>
    				<AudioRunTypeEnd/>
    			</AudioRunSounds>
    		</UnitArtInfo>
    


    Thanks for any help :)
    ~Civkid~
     

Share This Page