[General] Accessing Gameplay Constants in game?

Level 5
Joined
Apr 28, 2025
Messages
18
Is it possible to somehow access the gameplay constants at runtime?

I've tried using the console by typing in _G.TradingIncLarge and a bunch of other identifiers shown when selecting "Display Values As Raw Data", but it just returns nil.

I also tried printing out all the key-value pairs _G contains, which are 4954 and as far as I can tell contains the function definitions and constants from common.j, blizzard.j and my own script files. But I've only skimmed them, as there are so many, so maybe the gameplay constants are hidden in there.

I would love to make a map where you could modify these at the start of the game, to experiment with playing wc3 under alternative rules.

Does anyone have some info or ideas?
 
Damn it.:cry:

I learned that some of the gameplay constants are somewhat accessible through functions: I.e. SetPlayerState(p, PLAYER_STATE_FOOD_CAP_CEILING).

But there is still four specifically that I would to love to be able to modify somehow, namely:
1. "Hero XP Gained - Creep Reduction Table" - That is how much Hero xp is reduced from creeps based on its level.
2. "Upkeep - Food Levels" - That is when upkeep levels start. So 50 and 80 are the default values.
3. "Gold Tax Rates" - What gold upkeep should be at different levels.
4. "Real Seconds per game day" - Number of seconds per day.
 
3) Upkeep values are available as player state: Search - upkeep
Yeah I searched for those before, but UPKEEP_TIER1 and UPKEEP_TIER2 do no seem to be available at runtime (maybe because they are from common.ai?). But you can use SetPlayerState(player, LAYER_STATE_GOLD_UPKEEP_RATE, <integer value>) to set the upkeep rate, one would then need to make a system that monitors food supply and sets the upkeep rate accordingly. (This should be pretty straight forward with a periodic trigger, I think).
2) Edit: based on this, you can probably iterate and find out the limits before your map starts (by spawning units for a player and tracking when upkeep changes)
This is a good idea, though I think I would set all the values to 0 in the gameplay constants before to simply avoid having any native levels, and then adjust the upkeep rates when population thresholds are reached. Only thing is I don't know how to change the Low Upkeep/High Upkeep text in the top right corner, or even introduce more levels of upkeep?

It would be even easier I could just change the damn gameplay constants at runtime:sad:
4) Does seconds per day work at all?
I think so? I just tried setting them to 10, and it blasts through the day/night cycle, though it does seem to get a bit out of sync with the game time display pretty quickly. Third day/night change was at 37s...
This one is the least important one for me, though it would be still be nice to know how to modify.
 
Only thing is I don't know how to change the Low Upkeep/High Upkeep text in the top right corner, or even introduce more levels of upkeep?
It is. Just modify the following fields (marked by red boxes) in the World Editor, under the "Game Interface"
(make sure you enable the "Use Custom Game Interface" option first):
Upkeep WE.jpg
 
This is a very old feature. Look it up or ask around.
Typically me to think this would be overly complicated for some reason and not simply do a quick search to verify.
It is. Just modify the following fields (marked by red boxes) in the World Editor, under the "Game Interface"
(make sure you enable the "Use Custom Game Interface" option first):
View attachment 564420
Thank you! Very straightforward actually.
 
Back
Top