Jump to content
Null 45

Proposed design for a Regional Supply/Demand DLL

18 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

Interesting Concept for SC4.

You are sort of getting into the realm of the Transport Tycoon series of games. From your example my guess would be that the two oil wells would get their product to the refinery by an unknown means. It would be enough game wise just to have the two oil wells and a refinery in the game with no thought as to how to get the oil to the refinery. With the Transport Tycoon Series getting stuff like oil to the proper place was what those games were all about.

The Interesting Concept -  is such a Transport Mechanism even possible for SC4? Given the depth to which mods go things like trucks, rail cars, ships, planes, and even pipelines would be a possibility. The questions then arise, can the Transport Elements be coded and is such an addition to the game even desirable? The latter is doubtful given the limits of Autonoma coding. The desirability part would be up to the individual.

Even without a Transport Mechanism in place the concept is solid. From a City Building standpoint making a Transport Connection between two such elements on a strictly visual level would be very nice to look at.

  • Like 4

Humor is the second most subjective thing on the planet

Brevity is the soul of wit and vulgarity is wit's downfall

Good Night and Good Luck - Read You Soon

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    51 minutes ago, Nite Owl said:

    From your example my guess would be that the two oil wells would get their product to the refinery by an unknown means.

    Correct. The DLL would just be tracking the quantity of each resource type, it doesn't know anything about the cities or region. It is intended to provide a way to expand the region game play options, without involving the Maxis neighbor deal system.

    51 minutes ago, Nite Owl said:

    is such a Transport Mechanism even possible for SC4?

    As far as I know, the neighbor deal system is hard coded to support only the 3 utility deal types that Maxis implemented.

    But the game tracks every neighbor connection in the region, and DLLs can query that information. I wrote some code to test that tracking, and I was able to walk through a chain of 16 cities connected by power poles and water pipes. The same should apply to the other transportation networks. It was a fun experiment, but I don't have any practical use for that data. Maybe a cheat code that writes the info to a log file?

    • Like 6

    Share this post


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

    One idea which might pair with this supply and demand DLL is the successful Growable Freight End-Point experiment I did a long time ago. :ooh:

    The idea then was to have certain R, C, or I which would accept like 5 or 10 or 50 freight trucks to simulate having packages or supplies delivered. And while my additions did work, I seem to recall there was some trouble with freight trucks trying to all go to the closest receiving station and so a house accepting only 5 trucks would get overwhelmed in a big hurry.

    If some fancy DLL coding could convince the freight trucks to reevaluate their destination when their preferred end-point is at capacity this might then fully support @Terring's original concept. It would also resolve the trouble of having two or more Seaports where only one gets all the traffic and the other (even if adjacent) gets little or none depending on the city design.

    I still wouldn't expect any freight trucks would be aware of specific loads they carry, but by strategic city layout and development it might be possible to simulate that it is happening.

     

    • Like 6

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


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

    If some fancy DLL coding could convince the freight trucks to reevaluate their destination when their preferred end-point is at capacity this might then fully support @Terring's original concept.

    I wouldn't even know what game system handles that.

    I am having mixed success on the Lua side. I have not been able to get the Lua advice trigger to fire, even after setting the trigger value to 1. The following advice trigger is based on your Cori Reports trigger:

    Spoiler

     

    
    --#-package:0a76f001# -- package signature
    
    regional_suppply = {}
    
    
    sc4game.regional = {}
    sc4game.regional.trigger = function (guid) return 0 end
    
    -- Set up a trigger
    a = create_advice_cityplanning('434f5203')
    a.type = advice_types.CITY_PLANNING
    a.trigger  = "1"
    a.frequency = 1825
    a.no_timeout = 1
    a.persist = 1
    a.title = [[text@c8488101]]
    a.message   = [[text@c8488100]]
    a.priority  = 100
    a.mood = advice_moods.GREAT_JOB
    a.once = 0
    a.news_only = 0
    
    -- EOF

    But I managed to confirm that I can read Lua tables in C++, which would be required if I wanted to define my own table of C++ functions for the Lua code to call. That would be similar to what Maxis does for game.trend_slope.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    25 minutes ago, Null 45 said:

    I have not been able to get the Lua advice trigger to fire, even after setting the trigger value to 1.

    I'm out of time tonight, but I'll get you some code I wrote which is down & dirty for an always triggered Lua advice with a pop up display. Speaking of which, some of my triggers need Urgent Advice toggled on. *;)

    • Thanks 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


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

    I made a progression of 4 versions from the simplest down & dirty to the most common with the intention to write a tutorial explaining it for other first time coders, but it's been a busy day and I just don't feel like doing that right now.

    Not to worry tho. Since you are a programmer, you won't need any explanation from me. I'll send the 4th iteration via PM. I'll just mention the easiest way to use it is edit only inside the DoNullThings() function. *;)

    • Like 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    On 01/10/2024 at 5:29 AM, Null 45 said:

    The DLL would simulate a regional supply/demand system by implementing a region-wide resource pool. The resources would be exposed as a supply and demand building exemplar properties, with supply buildings adding X amount of a specific resource and demand buildings consuming X amount. The building supply/demand resource properties would be implemented as an Uint32 id/quantity pair.

    First, thanks for your work and creativity, bringing us innovations things to our old and dear game. *:thumb:

    There are a something that bothers me in the game: the region, in most part, is a set of isolated cities. For example, I can put builds pollutions generators in the corner and to affect just 1/4 of city, doing disapper 3/4 of pollution in the frontiers... :whatevs: hahahahaha

    Far from me to want resolve all isolations of cities, but if the propouse original of game, since 2003, was "think regionally" really, some resources should be collectives, even just in quantity: polices and fire stations, prisions, education, airport, simoleons, bonds, employs, seaports... *:read:
    I never did this test, but I think agreements with neighbors just work with border neighbors. For example, if I want create a power city in the center of region, can I distribute energy to all region? *:???:
    And a ociocity police officers or idle medicals in an city, could be use in others city?
    The international airport bring positive effect in others near cities?
    To where go border pollution?

    Well, I don't know that is this your proposal, but, if I got it right, we could think in resources that we already have and we can share between cities. If I didn't got it, I will be happy in the same way. *:)

    • Like 3

    "Nenhum sucesso no mundo compensa o fracasso no lar." - "No other success can compensate for failure in the home."
    Como fazer da sua família um time de sucesso! - How to make your family a successful team!
     

    Share this post


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

    There are a something that bothers me in the game: the region, in most part, is a set of isolated cities. For example, I can put builds pollutions generators in the corner and to affect just 1/4 of city, doing disapper 3/4 of pollution in the frontiers... :whatevs: hahahahaha

    I am not surprised that Maxis didn't simulate pollution across the region, it would have probably been to expensive to calculate. They had to simplify the traffic simulator so that the game could run on a 500 MHz Pentium 3.

    3 hours ago, carlosmarcelo said:

    Far from me to want resolve all isolations of cities, but if the propouse original of game, since 2003, was "think regionally" really, some resources should be collectives, even just in quantity: polices and fire stations, prisions, education, airport, simoleons, bonds, employs, seaports... *:read:

    The game allows you to share share commuters and utilities between cities, I have no idea if there were plans for anything beyond that. Based on the data in Ingred.ini there was an idea for certain ploppable buildings only existing in one city per-region (Regional Exclusion Group), but that feature was cut.

    2 hours ago, carlosmarcelo said:

    I never did this test, but I think agreements with neighbors just work with border neighbors. For example, if I want create a power city in the center of region, can I distribute energy to all region?

    Correct, but the game lets you chain neighbor deals between cities. I had tested that with a power deal chain consisting of 7 cities. I have no idea how well that works in practice, as opposed to just empty tiles with power lines.

    • Like 2

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    12 hours ago, carlosmarcelo said:

    I never did this test, but I think agreements with neighbors just work with border neighbors. For example, if I want create a power city in the center of region, can I distribute energy to all region? *:???:

    9 hours ago, Null 45 said:

    Correct, but the game lets you chain neighbor deals between cities. I had tested that with a power deal chain consisting of 7 cities. I have no idea how well that works in practice, as opposed to just empty tiles with power lines.

    Without @cogeo's or my tweaks it becomes an exercise in frustration. It is technically possible using Maxis's Neighborhood Deals code, but you have to make adjustments up and down your distribution chain so often that it ceases to be fun or useful.

    See here for solutions. *;) 

    A couple of things in favor of my mod is it allows significant over-buy as compared to the current city tile's needs (which facilitates easier long chain deals) and I made the garbage cost a fixed rate even when the destination city uses landfills. (Maxis code made adjustments based on the fullness percentage of the landfill and so their price could shoot up to 5x what it was when you started the deal and so it would get auto-cancelled.)

    • Like 2

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


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

    Not to worry tho. Since you are a programmer, you won't need any explanation from me. I'll send the 4th iteration via PM. I'll just mention the easiest way to use it is edit only inside the DoNullThings() function.

    Thanks, that popup is working. It took me a while to figure out how the Windows code layout differed from the Mac version, but once I got that working I was able to read Lua tables from the C++ side.

    My next test will be seeing if the regional_supply table I defined can take custom functions, similar to how SC4 uses the game table. I decided that it was easier to define my own table for the functions than to try and extend the Maxis tables. Based on the documentation in the BSC Daley Regional Tracking mod, it sounds like I will have to split that table off into its own Lua file and assign a low package number for other mods to use it. I may rename the regional_supply table to something else (regional_tracking?), but that decision can wait until I see if I can get the custom functions working .

    Maxis has an abandoned "Regional Exclusion Group" feature that may be fun to try and implement, ingred.ini describes that feature as: "For ploppable buildings: No more than one building within the specified group can be built in a single region.". Plus, if the custom functions work there will probably be more features that are candidates to add.

    • Like 2

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    1 hour ago, Null 45 said:

    I decided that it was easier to define my own table for the functions than to try and extend the Maxis tables.

    I like that idea a lot so we'd never have to worry about any conflict with the Maxis tables.

     

    1 hour ago, Null 45 said:

    Based on the documentation in the BSC Daley Regional Tracking mod, it sounds like I will have to split that table off into its own Lua file and assign a low package number for other mods to use it.

    That makes sense. Long, long ago I pulled all Lua code out of SimCity_1.dat and then created low package number controller files from which I could then load and compile Lua text files on the fly in the game. (I did have to exit to the Region screen after making and saving changes in my Lua code to have it be read and executed.)

    I've forgotten so much from then, but from empirical evidence at the time I split all the Maxis Lua into three groups which I called Region Memory, System Memory, and Game Memory and I had a very good single criterion for the difference between the latter two. (Tho I have no clue any longer what that was.)

     

    2 hours ago, Null 45 said:

    Thanks, that popup is working.

    Yay! And I suspect for what you need it'll be sufficient.

    If we go more advanced it's cool to have a ploppable lot with a unique Query GUID and then have CB make a custom panel like this:

    imgW10-3023.jpg

    :wub:

    • Like 3

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    4 hours ago, CorinaMarie said:

    If we go more advanced it's cool to have a ploppable lot with a unique Query GUID and then have CB make a custom panel like this:

    That would make a great query for some kind of Transportation building or Port/Train/Road Authority building.  Incredible.

    As for this overall mod, I think it sounds like a great plan.  Anything to extend the regional game aspects in a better manner is a great idea in my book.

    • Like 2

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    On 3/10/2024 at 2:01 AM, CorinaMarie said:

    If some fancy DLL coding could convince the freight trucks to reevaluate their destination when their preferred end-point is at capacity this might then fully support @Terring's original concept. It would also resolve the trouble of having two or more Seaports where only one gets all the traffic and the other (even if adjacent) gets little or none depending on the city design.

    I guess you're referring to my ideas suggested at an older topic of mine about adding and expanding traffic and vehicle behavior. The idea was to allow the freight trucks going to commercial and even residential zones too in order to simulate the purveyance of the shops and offices, like having the trucks transporting food from the farms to the restaurants and cars from the car industries to the car dealerships, as well as delivery orders from industries to residences, like ordering a new wire for your phone or spare parts for your car directly from the factory. Furthermore, shops and maybe even offices could also send goods and services to our Sims' homes by vans like these to simulate various types of delivering products and items, such as food and documents.

    So, let's simplify it a bit. Homes sends workers to shops and offices, and shops and offices sends goods and services to homes.

    R <--> C

    Homes sends workers to factories and farms, and factories and farms sends products to homes, shops and offices.

    R <--> I -> C

    On 4/10/2024 at 2:54 AM, carlosmarcelo said:

    There are a something that bothers me in the game: the region, in most part, is a set of isolated cities. For example, I can put builds pollutions generators in the corner and to affect just 1/4 of city, doing disapper 3/4 of pollution in the frontiers... :whatevs: hahahahaha

    Far from me to want resolve all isolations of cities, but if the propouse original of game, since 2003, was "think regionally" really, some resources should be collectives, even just in quantity: polices and fire stations, prisions, education, airport, simoleons, bonds, employs, seaports... *:read:

    This is something that have bothered me too. While awesome, the regional play of the game is still limited. For instance, pollution will not cross the city borders and airports will only support the commercial zones of the city they've been build. Why not making them work in regional scale instead of local? Why not having hospitals and schools helping the neighboring cities as well?  You may have a big hospital placed at the edges of a city but it can't provide medical support to it's neighboring cities as well, forcing you to build new hospitals in those cities.

    • Like 3
    • Yes 1

    "If you try to please everybody, you often times end up pleasing nobody, especially yourself. When somebody offers to do a favor for free, like making a mod for SimCity 4, you shouldn't be overly critical of something generously given to you. In other words, you shouldn't look a gift horse in the mouth." - Twilight Sparkle after playing SimCity

    "Being a mayor or a content creator for SimCity 4 is a heavy responsibility, Patrick. Each city and each custom content is like a child, and must be treated as such." - SpongeBob Squarepants after playing SimCity

    "Without deviation from the norm, progress is not possible." - Frank Zappa

    "The wisest men follow their own direction." - Euripides

    Welcome to Fairview, my new city journal *:D

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    On 2/10/2024 at 3:22 PM, Null 45 said:

    I wrote some code to test that tracking, and I was able to walk through a chain of 16 cities connected by power poles and water pipes.

    But why do neighbor connection still suck? I mean, you can easily get free power outta nowhere, even way more than the actual production capacity, by chaining 4 cities like a square. Not to mention the infamous eternal commuter bug. And this isn't even the most ridiculous one. You can even get billions of simoleans just from buggy auto-cancellation. I have experienced this many times.

    On 6/10/2024 at 2:59 AM, Terring said:

    Why not making them work in regional scale instead of local?

    I do really agree. It should be like seaports. The problem is we would break compatibility with existing controllers, including Maxis and those on Evermore.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    1 hour ago, Null 45 said:

    This should open up some interesting possibilities for DLLs to interact with the Lua system.

    Yay!

    While I don't have anything in mind myself, I really like this idea. *:)


    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    3 hours ago, Null 45 said:

    A small status update. I was able to get the custom C++ Lua functions working.

    Lua table code:

    
    regional_supply = {}
    regional_supply.get_resource_quantity = function(resourceID) return 0 end  -- Gets the resource quantity

    UI code:

    
    "regional_supply.get_resource_quantity(20)" result #regional_supply.get_resource_quantity(20)#

    Result:

    Custom-Cpp-Function-Lua-Result.jpg

    This should open up some interesting possibilities for DLLs to interact with the Lua system.

    The C++ code for registering the functions is similar to what SC4 uses to register the game functions, the Lua registration calls are identical. For whatever reason, SC4 adds the Lua function with a temporary name and then renames it. Skipping the renaming steps didn't work.

    The C++ callback functions also require some pointer math to get the current Lua instance from within the function, but it works. The math is the same across both the Windows and Mac versions of the game, so it is probably accessing a Lua storage area that the game is using to stash a pointer to the Lua instance.

    This is good news because it opens up new possibilities to extensive LUA mods such as AMPS

    • Like 4

    Federal Republic of SiculiaFederal Republic of Sonora

       Ain Member  Wiki

    NAM Team - Co-developer of Pedestian Revolution Mod - Railway Department (Hybrid Railway | HRW Expert) - MTA Member - BAT Creator

    Ulisse Wolf YouTube Channel - Ulisse Wolf Mastodon Profile

    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