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

[Tutorial] In-Game Cheats, Modding, & Debugging Using Console Commands

Discussion in 'Civ4 - Modding Tutorials & Reference' started by StarDuster, Dec 2, 2005.

  1. StarDuster

    StarDuster Chieftain

    Joined:
    Nov 30, 2005
    Messages:
    7
    The following may be used to "cheat", modify, and/or debug any currently running Civilization IV game "on-the-fly". I have not tested/used all of the console lines. Feel free to tinker with them but always remember to save your current game first!

    Warning: This procedure involves editing a game file. Be sure to create a backup copy of the "CivilizationIV.ini" file before proceeding.

    Use a text editor (such as Notepad, do NOT use Wordpad) to edit the "CivilizationIV.ini" file located in "C:\Documents and Settings\[Your Windows Log On Name]\My Documents\My Games\Civ4\"

    Open the file and search for the line of text "CheatCode = 0". Change this line to "CheatCode = chipotle". Save the file. Now start a game and press "~" during game play to display the console window.

    The following are a list of console lines along with their functions. The description of the console line will appear in bold black letters while the console line itself will appear in bold red letters.

    Some commands require you to enter variables (such as an amount of gold or x-y coordinates). A brief description of the variable will be found within [ ] brackets in the console line.

    Also, keep in mind that the following commands are case sensitive.

    Example:
    Set player's gold (0 is active player) - Player.setGold [player number=""] [value]

    Therefore, to change your gold to 5000, you would enter the line:
    Player.setGold 0 5000

    Pretty simple huh. :goodjob:


    Effect - Code
    Display all console window command lines - help
    Stop music - Sound.noMusic
    Reload audio scripts - Sound.reload
    Stop Soundscape from playing - Sound.stopSoundScape
    Play sound - Sound.play string [filename]
    Finds entities with black emissivity - Graphics.FindBlackPlotsAndCities
    Hide attachables - Graphics.HideAttachables
    Force light update on all entities - Graphics.ForceLightingUpdate
    Rebuild terrain and lighting - Graphics.ReBuildTerrain
    Set Hill scale - Graphics.SetHillScale [floating number=""]
    Set Peak scale - Graphics.SetPeakScale [floating number=""]
    Set water plane height - Graphics.setWaterHeight [floating number=""]
    Set render depth for quad tree - Graphics.quadTreeDepth [integer]
    Toggle water - Graphics.toggleWater
    Display terrain - Graphics.displayTerrain
    Toggle grids - Graphics.toggleGridMode
    Dump texture palette - Graphics.showTexturePalette
    Set texturing - Graphics.setTextureMode
    Set wireframe - Graphics.setWireframe
    Morph the globeview count times - Profile.morphGlobe [integer]
    Rebuild city indicated number of times - Profile.rebuildCity [x coordinate=""] [y coordinate=""] [integer]
    Rebuild plot indicated number of times - Profile.rebuildPlot [x coordinate=""] [y coordinate=""] [integer]
    Dump animation information to debugging window - Profile.dumpAnimLog
    Set minimum time to capture spikes. (set to 0 to disable spikelock) - Profile.setSpikeThreshold [milliseconds]
    Dump console command history - Console.History
    Write HTML documentation for the current console commands - Console.CreateDocumentation [filename]
    Clear the console - Console.Clear
    Display current logging status - Log.status
    Toggle logging - Log.toggle
    Clear the log file - Log.clear
    Erase units and cities from map - Map.empty
    Fill map with units and cities for performance testing - Map.fill
    Replot Goodies - Map.generateGoodies
    Replot Bonuses - Map.generateBonuses
    Replot Features - Map.generateFeatures
    Replot Rivers - Map.generateRivers
    Erase Rivers, Features, Bonuses and Goodies - Map.eraseGameElements
    Replace Rivers, Features, Bonuses and Goodies - Map.replaceGameElements
    Change the active landscape info - Map.setActiveLandscapeID [landscape number=""]
    Erase all plots - Map.erasePlots
    Reload Game Text xml files - Xml.reloadGameText
    Reload Civ4TerrainSettings.xml - Xml.reloadLandscapeInfo
    Reload Civ4ArtDefines.xml - Xml.reloadArtDefines
    Toggle output of texture loads/accesses to debug output - Game.toggleTextureAccessInfo
    Force AI to play for indicated number of turns - Game.AIPlay [integer]
    Create sequences associated with the selected unit - Game.createSelectedUnitKFs
    Free sequences associated with the selected unit - Game.freeSelectedUnitKFs
    Save WorldBuilder save description file - Game.saveWorldBuilderSave [filename]
    Toggle Animation Test Tool - Game.toggleAnimationTest
    Show GFC directory chooser - Game.gfcDirChooser
    Show GFC file dlg window - Game.gfcfiledlg
    Show GFC test popup - Game.testGFC [integer]
    Show test popup - Game.testFont bool bEnable
    Show the Python test popup - Game.testPythonPopup
    Show test popup - Game.testPopup
    Scroll to the bottom - Game.scrollBottom
    Scroll to the top - Game.scrollTop
    Clear the listbox below - Game.clear
    Display the help popup - Game.helpScreen
    Toggle debug mode - Game.toggleDebugMode
    Debugging - Game.showWBPalette bool bCreate
    Compute md5 checksum for the directory tree specified - App.calcFolderChechsum [directory]
    Set debugging value - App.setMooseDbg1 [integer]
    TGA full screen shot in Screenshot folder. (requires "AllowScreenShots=1" in "CivilizationIV.ini") - App.takeFullScreenShot
    TGA screen shot in Screenshot directory. (requires "AllowScreenShots=1" in "CivilizationIV.ini") - App.takeScreenShot
    Set maximum frame rate. (0 to disable) - App.setMaxFrameRate [floating number=""]
    Update existing value in the ini file - App.setIniFile [group key=""], [key] [value]
    Crash game - App.crash
    Return the application link time - App.getBuildTime
    Test player unit iteration - Player.testUnitIter [integer]
    Change players gold. (0 is active player) - Player.changeGold [player number=""] [value]
    Set players gold (0 is active player) - Player.setGold [player number=""] [value]

    These are all of the commands that I am currently aware of. I will add more as they are discovered or come to my attention. If you are aware of any that are not listed here, please feel free to share them.
     
  2. kandalf

    kandalf Warlord

    Joined:
    Sep 23, 2005
    Messages:
    116
  3. StarDuster

    StarDuster Chieftain

    Joined:
    Nov 30, 2005
    Messages:
    7
    aaah yes. app.crash - a must-have requirement for any Windows-based game :D
     
  4. tbear2520

    tbear2520 Warlord

    Joined:
    Oct 28, 2005
    Messages:
    103
    OK, I have a problem when trying to do anything in the console. Here is a screen shoot of the error message. Any ideas? I have uninstalled and reinstalled Civ 4. My version is the latest. All current patches have been applied.



    Any help, PLEASE!!!
     
  5. Junuxx

    Junuxx Emperor

    Joined:
    Sep 6, 2005
    Messages:
    1,153
    Location:
    the Netherlands
    I haven't tried it myself but I think it's case-sensitive tbear. The B in generateBonuses needs to be in upper case.

    Very useful tutorial by the way.
     
  6. StarDuster

    StarDuster Chieftain

    Joined:
    Nov 30, 2005
    Messages:
    7
    You are correct Junuxx and thank you for bringing that to my attention. I will add that note to my original post.

    Thanks :)
     
  7. tbear2520

    tbear2520 Warlord

    Joined:
    Oct 28, 2005
    Messages:
    103
    While I agree that the thing is case sensitive, I don't believe that that's my issue. Here's another screen shot.


    Any help? Thanks

    Clearly I have a map open
     
  8. Junuxx

    Junuxx Emperor

    Joined:
    Sep 6, 2005
    Messages:
    1,153
    Location:
    the Netherlands
  9. apowell

    apowell Chieftain

    Joined:
    Dec 6, 2005
    Messages:
    2
    Location:
    Calgary
    You appear to be trying to call a function. Try adding parentheses after the name:

    map.generateBonuses()

    or something similar.

    Python function calls are a lot like C. The name of the function is just a pointer to the address where the function starts. Or so my memory tells me.

    Cheers
     
  10. Blkbird

    Blkbird King

    Joined:
    Oct 29, 2005
    Messages:
    860
    But if an AttributeError occurs saying "Object has no property named XYZ", then that includes any methode. So there definitely isn't anything - "callable" or not - of that name.

    But "Map" clearly isn't equal to "map", is it?
     
  11. iSkratch

    iSkratch Chieftain

    Joined:
    Dec 28, 2005
    Messages:
    57
    I've noticed that Civilization 4 seems to quite often decide to demonstrate this "feature" at random times while playing, how nice of them! :p

    Also, see the bottom of this page for some more useful ones, although a couple don't seem to work.
     
  12. Craig_Sutter

    Craig_Sutter Deity

    Joined:
    Aug 13, 2002
    Messages:
    2,747
    Gender:
    Male
    Location:
    Calgary, Canada
    I've been trying to get the cheat to work in World Builder as well... I type ~ and get the input screen for it... however, any command I type in gives no result...
    after the >>: I type in help and hit enter, and get 'help' is not defined...

    So I can't even get the help command to work, let alone any of the others.

    I know nothing about python, or how to enter commands... am I missing something obvious to someone more knowledgable about programming.
     
  13. ensignyu

    ensignyu Chieftain

    Joined:
    Nov 12, 2005
    Messages:
    14
    Well, I'm not sure if it's been mentioned anywhere else, but for me, hitting shift-tilde (shift and ~) brings up a Python interpreter console (notice the >>, as opposed to the single > used by the cheat console) that tbear mentioned. Very handy for debugging Python mods.
     
  14. Olleus

    Olleus Deity

    Joined:
    Oct 30, 2005
    Messages:
    6,478
    Location:
    England
    wtf i cant get the console screen up i press [SHIFT-#] (which makes ~) and also tried just pressing #. I have checked my .ini file a million times and it still doesn't work!! I have the european version of the game that might have soomething to do with it. If someone could tell me what noobish error i am making it would be very helpful as i am trying to add python into my mod and being able to test functions would be very handy.
     
  15. ensignyu

    ensignyu Chieftain

    Joined:
    Nov 12, 2005
    Messages:
    14
    I don't know anything about the European version, but I think some site mentioned control-shift-c for some unclear purpose. Try that.
     
  16. Granias

    Granias Chieftain

    Joined:
    Nov 3, 2005
    Messages:
    34
    Location:
    The Netherlands
    I've got the European version to and it works for me. Are you sure SHIFT-# makes the ~? Try pressing the button without shift.
     
  17. Crash757

    Crash757 King

    Joined:
    May 30, 2003
    Messages:
    905
    Location:
    Riga, Latvia
    Doesn't work. Says "done", but nth happens :(
     
  18. Snerk

    Snerk Smeghead

    Joined:
    Jan 16, 2006
    Messages:
    7,609
    Gender:
    Male
    Location:
    Norway. You'll never leave
    It doesnt work. I have edited the civilizationIV.ini file,
    then i says i have to press ~ to acces the console window.
    But nothing happends when i press ~ !
    The idea is to press ctrl + alt + "the button with the ~ symbole on" when your in a game right? well nothing happens, can someone help?
     
  19. mikezang

    mikezang Pegasus

    Joined:
    May 6, 2002
    Messages:
    465
    Location:
    Tokyo
    How can I use same function in python files?
     
  20. StarDuster

    StarDuster Chieftain

    Joined:
    Nov 30, 2005
    Messages:
    7
    This isn't for the World Builder.

    It is for in-game use...and yes, it does work. I have been using it for months (US vanilla version).
     

Share This Page