Add resources income

Asked by Remi Dhellemmes on 2020-01-10

Hello everybody, and happy new year 2020 !

I am working on a mod for Wargus to modify Warcraft II gameplay (add new upgrades to buy, put shield/sword/axe upgrades on 5 levels instead of 2, possibility to upgrade guard/cannon towers to increase its strengh up to have a level 3 tower, the possibility to upgrade spells...), but there is something I can't do.

Can someone tell me how to add the possibility for a building to produce resources over time ?
If I want for example that the town hall produces 1 gold every 5 seconds, what should I add in scripts > human > units in the town hall section ?

I already know for example that if I add a line with "RegenerationRate = 1,", I give to the unit/building the capacity to regenerate Hitpoints, but if I want resources over time ?

I am sure there is a way to do it, I noticed that in the "For the Motherland" campaigns, we earn permanently resources over time (100 gold, 50 wood and 50 patrol every 30 steps, to be exact), but i can't find any trace of that in files. I tried everything but nothing works (when I add something that the computer can't read, Wargus does not start, but it works again if I delete it).

Can anybody help me ?

Question information

French Edit question
Wargus Edit question
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Kyran Jackson (erstmap) said :

Wargus has moved to Github here:

The script which modifies the resources in For the Motherland is handled by the ai in \scripts\ai\ai_redribbon_2014.lua

The function AiRed_Resources_2014(playerid, gold, wood, oil) gives a player resources.

Revision history for this message
Kyran Jackson (erstmap) said :

A building generating resources was done in the Stratagus spinoff BOS Wars.

Revision history for this message
Remi Dhellemmes (morkatos) said :

Yes, I see, it was in the "AI" files whereas I tried to find in "scripts", "maps" and "campaigns" files.

You are right for BosWars, the function is "MagmaProductionRate = 12," (for magma pump) and "EnergyProductionRate = 20," (for power plant), it is possible to change it, it's easy to get a building to produce resources by simple copy and paste (I can tell you, I even tried to copy this in the Wargus file to have the same thing in Wargus !).

I have been trying to have the same for 2 weeks in Wargus with gold in Town hall, without succes !

Thank you for your answer, Kyran, I now know where the income comes from in the FTM campaigns.

But have you got an idea about how to apply this on a building (like in Bos wars) ? The function to add in the "units" files ?
I tried the function you sent me, but it doesn't work in this file.

I need to change something here, but what ?

Revision history for this message
Kyran Jackson (erstmap) said :

That function only works when the AI is being used.

There is no way to make a unit generate income in Stratagus without using the AI trick.

BOS Wars has a modified engine allowing that functionality.

Revision history for this message
Remi Dhellemmes (morkatos) said :

Thank you for your answer, Kyran, I am just a little disappointed that Stratagus does not allow this kind of action easily.
We should ask the creators of Stratagus if they could add this functionality.

Currently, the only way I have found is to put a negative repair cost for Town hall (provides gold), for Lumber mill (provides wood) and for Refinery (for patrol), it also damages the buildings instead of repairing it (but these buildings can self-repair).
It works, but it is not perfect (for example, I need first damage a building each time, and AI doesn't take advantage of that).

But I imagine that it may be possible to make in the AI file a script adding resources income depending of the number of buildings of a certain type you have, no ?
Could a small modified version of the function AiRed_Resources_2014(playerid, gold, wood, oil) with some buildings dependencies added, perform this function ?

If you (or anyone else) find how to do that, I am very interested :-) !
The rest is simple, I just have to copy it in every AI file present in Wargus > scripts > AI, and voila !

Can you help with this problem?

Provide an answer of your own, or ask Remi Dhellemmes for more information if necessary.

To post a message you must log in.