Sim City 4 Devotion Forums

SimCity 4 Devotion Custom Content Showcase => Other Projects => Topic started by: CasperVg on September 06, 2019, 04:47:31 AM

Title: DLL-modding for Hotkeys - AutoSave & AutoHistorical
Post by: CasperVg on September 06, 2019, 04:47:31 AM
I've recently found that, by combining simmaster07's excellent work on gzcom-dll (https://github.com/nsgomez/gzcom-dll) and ebina's work on KEYCFG modding (https://sc4devotion.com/forums/index.php?topic=9503.0) in 2009 - we can actually use DLL plugins to create new programming functions that are triggered by hotkeys.

So far, what we can actually do within those functions is still somewhat limited by the classes that simmaster07 decoded, but a number of things that I have been able to do:

- Assign a hotkey that automatically adds/removes $100k to your city budget each time it is pressed
  * Uses cISC4BudgetSimulator
- Assign hotkeys to automatically make all lots in a city historical, or to stop all lots in a city from being historical, or to toggle historical status of all lots in the city.
  * Uses cISC4LotManager and cISC4Lot
  * sim_16 has recently managed something similar over on Simtropolis (https://community.simtropolis.com/forums/topic/758258-modifying-sc4-savegames-it-is-possible/), but his solution requires savegame editing - which means you need a separate tool and need to close to game.

The hotkeys I have added are as following:

For good measure I have also added an extra cheatcode: AutoHistorical.
When this cheat code is activated, the game will automatically mark all lots as historical every 1st day of the Month. To disable it, just enter it again.

To test what I have so far:
1. Download the ZIP file in the attachment
2. Move the files CAS_AutoHistorical_v0.0.1.dat and CAS_AutoHistorical_v0.0.1.dll to your plugin folder root.

If you have suggestions on other things you would like hotkeys for, let me know in the comments  ;)

EDIT: Attachment removed. A newer version is available here (https://sc4devotion.com/forums/index.php?topic=18501.msg532936#msg532936)
Title: Re: DLL-modding for Hotkeys - Automatically mark all lots as historical
Post by: metarvo on September 06, 2019, 07:29:37 AM
This is one of those things I didn't even consider until I saw it... but now I can see the potential.  Certain types of city-building styles benefit greatly from historic status.  For instance, I could imagine it would work wonders for diagonal residential neighborhoods when one has taken the time to grow a row of houses just so.

Nice work, Casper! :thumbsup:
Title: Re: DLL-modding for Hotkeys - Automatically mark all lots as historical
Post by: alejogc13 on September 06, 2019, 08:00:10 AM
Is it possible to force the alpha blend with your method?

https://en.wikipedia.org/wiki/Alpha_compositing

https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-blend-state

https://docs.microsoft.com/en-us/windows/win32/direct3d9/texture-alpha

No Alpha Blend:

(https://cdn.discordapp.com/attachments/393834822696697866/612034605058621451/nobleding.png)

Alpha blend:

(https://cdn.discordapp.com/attachments/393834822696697866/612034600256012328/50be.png)
Title: Re: DLL-modding for Hotkeys - Automatically mark all lots as historical
Post by: Andreas on September 06, 2019, 01:57:23 PM
This is rather intriguing alright! You guys never cease to amaze me, impressive what you can do with such an old game. I wonder if you could create a hotkey for "fixing" the "water graphics bug" that always occurs when using lots with no base texture, and you switch to underground view and back.
Title: Re: DLL-modding for Hotkeys - Automatically mark all lots as historical
Post by: Tyberius06 on September 06, 2019, 03:51:19 PM
Casper, these are really awesome developments! The make things historical hotkey and cheat alread my favoutire, since my gameplay is heavily depending on certain buildings to grow next to each other and I only want to keep certain buildings.
I don't know if the +1 reputation option is still available with the new SC4D, but I would like to give you +1 for this development.

- Tyberius
Title: Re: DLL-modding for Hotkeys - Automatically mark all lots as historical
Post by: mattb325 on September 07, 2019, 01:10:57 AM
Wow, this is excellent stuff indeed, Casper!
It's these sorts of amazing new findings that will really help keep this old game alive.  :thumbsup:
Title: Re: DLL-modding for Hotkeys - Automatically mark all lots as historical
Post by: mgb204 on September 07, 2019, 04:48:08 AM
I don't know if the +1 reputation option is still available with the new SC4D, but I would like to give you +1 for this development.

Done!
Title: DLL-modding for Hotkeys - AutoSave & AutoHistorical
Post by: CasperVg on September 07, 2019, 10:57:52 AM
@metarvo: Indeed that was one of the use cases I had in mind, along with people who like to grow thematic neighbourhoods and then want to keep them intact (like Tyberius mentioned).
@alejogc13: I'm not very familiar with alpha blending (or the rendering of models in game in general). There is a RenderProperty called "ForceNoAlphaBlend" currently in the game, which can be activated from the command line, I believe. However, the opposite (ForceAlphaBlend) is not available - but I would presume the game defaults to using alpha blend? Do you know in which cases it doesnt?
@Andreas: Might be possible to hack a hotkey in that switches to the zone data view and then back to the normal view successively. IIRC switching to the zone data view is the current workaround, right? I don't think those methods/classes have been decoded yet, however - so it might take some time.



I come to you today with v0.0.2 of the mod. It contains one bugfix and one new feature.

- Bugfix: I accidentally included an experimental KEYCFG, which meant that the Road hotkey (R) no longer worked with it installed. v0.0.2 reverts to the default configuration, with only hotkeys added and none changed.

- Feature: Autosave
Autosaving functionality used to be requested a lot to reduce the impact of those pesky CTDs. However, since simmaster07's SC4Fix solved the most common source of CTDs (puzzlepiece-over-TE), it has become not as critical. However, it now exists anyway :D

The new functionality in detail:

Note:To reduce saving time and to avoid the pesky 'City has been saved'-dialog, this DLL uses the games' QuickSave routine. This is quite a bit quicker (though still significant on large, built-up cities). It does, however, not update the city preview images for the region view. So it's still advised to do a full save when you quit the game, so that those previews are updated.
Note:Because the auto saving routine is triggered by game time (and not IRL time), it doesn't work if your game is paused. I will explore in the future if there is some way to trigger it via real time as well.

Please find v0.0.2 in the attachment. Just replace the existing .dat and .dll files with the new ones to update.[/list]
Title: Re: DLL-modding for Hotkeys - AutoSave & AutoHistorical
Post by: AsimPika3172 on September 07, 2019, 05:52:09 PM
Cool!  :thumbsup: &apls &apls &apls :bnn:
Title: Re: DLL-modding for Hotkeys - AutoSave & AutoHistorical
Post by: Shiftred on September 07, 2019, 09:28:39 PM
This is great! In just a few minutes it has proven to make my play style much easier.
Title: Re: DLL-modding for Hotkeys - AutoSave & AutoHistorical
Post by: Jasoncw on September 13, 2019, 02:34:54 PM
Incredible!!