Jump to content
Null 45

A DLL experiment in adding new ordinances to the game

5 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

This is a DLL Plugin for SimCity 4 that experiments with adding a new ordinance to the game. The game's ordinance simulator is one of the few systems that allows a DLL to add new code for the game to use in its simulations.

The plugin will show up in the ordinances list as New ordinance test1. The ordinance is an expense ordinance with the same monthly cost as the Power Conservation ordinance (-0.005 x city population).

The plugin currently sends the following ordinance effects to the game: Mayor Rating, Commercial Demand Effect, Travel Strategy Modifier and Air Effect by zone type. All of those effects are using the default values from Ingred.ini, so they shouldn't have any in-game effect.

Disclaimer - This mod is experimental, you probably should not test it in a city you care about.

Features:

  • Adds a new ordinance into the game that does not replace any of the built-in ones.
  • Allows the ordinance to have a custom monthly cost calculation or availability conditions (e.g. starting year or specific buildings that must be in the city).
  • The game persists the ordinance's state to the city save file.

Limitations:

  • The available ordinance effects are restricted to the ones that Maxis already included in the game.
    • These effects are hard-coded into the various game systems, e.g. the Travel Strategy Modifier behavior is hard-coded into the traffic simulator.

Download: https://github.com/0xC0000054/sc4-add-new-ordinances/releases/latest

System Requirements

Windows 10 or later.

Installation

  1. Close SimCity 4.
  2. Copy SC4AddNewOrdinance.dll into the Plugins folder in the SimCity 4 installation directory.
  3. Start SimCity 4.

Source Code

The plugin source code is located on GitHub: https://github.com/0xC0000054/sc4-add-new-ordinances

The Source Code section of the readme contains build instructions and an overview of the source code layout. The DLL will write a SC4AddNewOrdinance.log file with status information to the folder it is located in, and a debug build will write the same information to the debugger console.

  • Like 6

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Release version 0.0.2, which fixes the ordinance cost calculation bug and logs the SC4 ordinance API calls to a file.

    • Like 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    The DLL can now persist the custom ordinance state to the city save file, the game will call my DLL code to handle the required processing when loading and saving a city. I have not posted a binary release for this change because it would just add a useless ordinance to the save game, and may have other unintended effects that I missed.

    The custom DLL still has some limits when compared to what Maxis could have done, e.g. I cannot add new ordinance effects beyond the 36 that Maxis added as the those are hard-coded into the various game systems. I also don't have access to the game's property/exemplar parsing code, so the ordinance name, description and effects are hard-coded into the DLL.

    I have not been able to come up with a file format that would allow users to write their own ordinances to insert into the game, one of the main difficulties is all the different data types that the ordinance effects use.

    I think the game may allow DLLs to access the system that it uses to get data from the DAT files, but I am not sure if that system is available when SC4 loads DLLs (which is when the game requires the ordinance IDs to be registered in-game). But that may be useful for other possible DLL mods. As I mentioned above, the DLL would have to do its own parsing of any data it requests.

    For reference, here are the 36 built-in ordinance effects. I originally compiled this list as part of my ordinance property system debugging code.

    Spoiler
    
    ID - Name (Data Type)
    
    0x28ed0380 - Crime Effect (float32[1])
    0xaa5b8407 - Mayor Rating (int32[1])
    0x08f79b8e - Air Effect (float32[1])
    0x28f42aa0 - Flammability Effect (float32[1])
    0xe8f79c8b - Water Effect (float32[1])
    0xe8f79c90 - Garbage Effect (float32[1])
    0xa8f4eb0c - Water Use Reduction (float32[1])
    0x0911e117 - Power Reduction Effect (float32[1])
    0x2a633000 - Commercial Demand Effect (float32[1])
    0x2a653110 - Demand Effect:Cs$ (float32[1])
    0x2a653120 - Demand Effect:Cs$$ (float32[1])
    0x2a653130 - Demand Effect:Cs$$$ (float32[1])
    0x2a653320 - Demand Effect:Co$$ (float32[1])
    0x2a653330 - Demand Effect:Co$$$ (float32[1])
    0x2a634000 - Industrial Demand Effect (float32[1])
    0x2a654100 - Demand Effect:IR (float32[1])
    0x2a654200 - Demand Effect:ID (float32[1])
    0x2a654300 - Demand Effect:IM (float32[1])
    0x2a654400 - Demand Effect:IHT (float32[1])
    0x491b3ad5 - Health Coverage Radius % Effect (float32[1])
    0x891b3ae6 - Health Effectiveness vs. Distance Effect (float32, general response curve)
    0xe91b3aee - Health Quotient Boost Effect (float32[1])
    0xc92d9c7a - Health Quotient Decay Effect (float32[1])
    0x092d909b - Health Capacity Effect (float32[1])
    0xe92d9db4 - Health Effectiveness vs. Average Age Effect (float32, general response curve)
    0xa91b3af4 - School Coverage Radius % Effect (float32[1])
    0xa91b3afa - School Effectiveness vs. Distance Effect (float32, general response curve)
    0xa92d9d7a - School EQ Boost Effect (float32[1])
    0x692ef65a - School EQ Decay Effect (float32[1])
    0x892d9d02 - School Capacity Effect (float32[1])
    0xc91b3b02 - School Effectiveness vs. Average Age Effect (float32, general response curve)
    0x8a612fee - Travel Strategy Modifier (int32[9])
    0x8a67e373 - Air Effect by zone type (float32[16])
    0x8a67e374 - Water Effect by zone type (float32[16])
    0x8a67e376 - Garbage Effect by zone type (float32[16])
    0x8a67e378 - Traffic Air Pollution Effect (float32[1])

     

    I am not sure what more I can do with this DLL experiment, other than trying to design the custom ordinance file format I mentioned above. Ideas would be welcome. *:)

    Most of the above was cross-posted from here.

    • Like 3

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Looks like a cool feature. Would this work with CAM?

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    5 hours ago, Max4k said:

    Would this work with CAM?

    What do you mean?

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account


    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Exchange.
    Make a Donation and get one or all three discs today!

    STEX Collections

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections