-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation typo/incorrect information? #445
Comments
Consider that documentation hasn't being updated for 7 years it is possible to find some typos but regarding this
From what I understand, you're trying to make an upgrade that costs X metal. I believe that metal is one of the resources already defined in the engine but if you want to make an upgrade to have that cost you can take a look on how upgrades are defined in Wargus. |
That is not what I am attempting to do. I am trying to make it so the upgrade increases the production cost of the units that benefit from the upgrade (this is meant to be a more significant upgrade that comes with drawbacks.) Unfortunately, the documentation appears to show an incorrect way of formatting that scripting and there doesn't appear to be a right way at the moment. Unfortunately, my attempts at digging through the scripting system in Stratagus only confused me further as it appears that it's referencing a separate function to retrieve a resource ID that isn't working or expecting it formatted that way. Unfortunately, I lost my notes on what I had found or I would post them here. |
One way to do this is, after the upgrade is completed, the unit affected from this will be transformed into another unit, similar on how WarCraft II does with Knights to Paladins and Ogres to Ogre-Magi. What I'm trying to say is that you have to define a new unit type that has the same sprites, buttons, stats etc, but with the increased cost on the resource.
As I have already wrote yesterday, that documentation is old and it isn't updated for 7 years.
To me, the function you're searching is called CclDefineModifier and the lines about changing the cost of a unit type are defined here. stratagus/src/unit/upgrade.cpp Lines 290 to 296 in 8720f1f
|
The problem with doing that is that there will be more than one of these upgrades. I don't know if I can, or want to, make a new unit for every combination of these late game cost modifying upgrades. I was even considering making it so every level of the upgrade has a slight production cost increase. The question is, how is this cost upgrade suppose to be formatting in the script? Or is it broken? |
Your last code is correct. I don't know why you get unknown resource cost, the C++ code should be looking at the "metal" string, so there's a bug somewhere. Doing it via new units is a bit annoying, yes. One thing, you don't have to define two units, you can use CopyUnitType and then use DefineUnitStats to change the costs. But yes, a bit annoying if you have many combinations of upgrades that each affect the costs differently. Maybe @Jarod42 will have a minute to check why the piece of code that @SimoneStarace linked doesn't work, because to my eyes it should. I just don't even have a dev environment for stratagus set up anymore, so I can't quickly jump in and debug |
Okay. I'll leave it as the last one, but commented out, and wait for an update on this. Just as a sanity check, I did try changing out the resource for a few others in my project to see if it was having trouble looking up metal for some reason and it made no difference. I lost my notes on looking through the LUA scripting, but if I remember correctly, it's looking up the resource using a different function that other parts of the engine use to look up a resource ID. Going off the results in stderr.txt, it looks like it's trying to pass the word "cost" to the resource lookup function instead of the resource name. |
I believe I have found a typo in the documentation when trying to make a specific research increase the production cost of a unit and possibly something that was rewritten at some point in a way that is different from how it is documented.
I've attempted to figure out where the typo is by attempting the following in my upgrade.lua script:
{"cost", ("metal", 50}}, yields [string "scripts/human/upgrade.lua"]:125: ')' expected near ','
{"cost", ("metal", 50)}, yields [string "scripts/human/upgrade.lua"]:125: ')' expected near ','
{"cost", "metal", 50}, yields incorrect argument
{"cost", {"metal", 50}}, yields Resource not found: cost
I'm unable to figure out the correct way to use this tag. I had hoped to figure this out myself and then update the documentation lines, but it seems I can't figure out how it works.
Lines in documentation describing the cost tag on research: https://github.com/Wargus/stratagus/blob/8720f1fbb0f74296076e312d3c30a2084707add6/doc/scripts/research.html#L222C1-L224C45
The text was updated successfully, but these errors were encountered: