Changing tech cost in-game

lemmy101

Emperor
Joined
Apr 10, 2006
Messages
1,064
Anyone have any ideas how to do this? :/

Setting the cost of things in-game using Modding.PerformAction or DB.Query don't have any in-game effect, even though the set performs correctly on the DB, suggesting that the data is cached by the game.

Problem is the core, most important and if I do say so myself, the best bit of our mod relies on the notion of changing a tech's cost on the fly during the game.

1) It needs to be for one player only, so each has their own cost. I figured I could do this by having 16 identical appearing techs and disable all of them, assigning one per player via removing one 'Civ_DisableTech'
2) The cost needs to be able to change arbitrarily, up 50 points, down 100 points.
3) It needs to work for the AI so simply lowering the player's research invisibly when they come to research it would be bad since the AI would proably fail to evaluate this and get stuck in a trap if the tech was as good as infinite research time.

Any suggestions? :S

TIA,

lemmy
 
you could manually adjust research progress for each civ, although from a player's viewpoint its going to be confusing why progression is being changed
 
you could manually adjust research progress for each civ, although from a player's viewpoint its going to be confusing why progression is being changed

3) It needs to work for the AI so simply lowering the player's research invisibly when they come to research it would be bad since the AI would proably fail to evaluate this and get stuck in a trap if the tech was as good as infinite research time.

:p

Seriously tho yeah this looks like the only solution at the moment. :(
 
teamtech:ChangeResearchProgress() is what i meant, that changes the amount put into a research and you can use that on AI/player

but yeah theres nothing readily available to change the db's cost value. the game is constantly querying the db so even changing something in GameInfo isn't going to do it. unless there's a table that stores the sql result that we can access i think its safe to say this is one of those wait for the source things
 
i think the AI would just keep on researching until done. have you seen an AI switch research project? i always assumed it continued until finished, like city builds or unit orders
 
yeah but the idea with the mod is with high piety it could take 200 turns to research the tech in question hence this is exdactly why it's a problem :(

EDIT: Now I'm back and off my stupid phone, I can reply in full. :D

Basically the Enlightenment tech in our religion mod's cost scales based on the amount of generated piety, so while you are researching it the cost continues to rise. The AI would need to be aware of this cost change otherwise, if it was getting 40 beakers and 40 beakers were being removed from the tech progress each turn, then while the tech would appear to it to take '6 turns' it would in reality be an infinite amount of time, so the AI would just sit there researching it forever always thinking it was only 6 turns away.

If however the price of the tech changed, then by the time the AI got to it, if their piety was too high it would likely already be way too high a cost for the AI to decide to research it in the first place.
 
>snip<
If however the price of the tech changed, then by the time the AI got to it, if their piety was too high it would likely already be way too high a cost for the AI to decide to research it in the first place.

Perhaps add something to the piety buildings about the tech.. like the Building Resources mod... Maybe even modify what that mod does.. instead of changing 1 resource to another, have it change the 'tech' to 'piety'.

The building resources mod updates every turn, so in theory, if you can make that work, then the tech/piety would adjust every turn as well.

(my brain isn't fully 'on' tonight... tired, but I thought I'd kick the idea to you... I can't even think if it's doable atm :/)
 
yeah but the idea with the mod is with high piety it could take 200 turns to research the tech in question hence this is exdactly why it's a problem :(

EDIT: Now I'm back and off my stupid phone, I can reply in full. :D

Basically the Enlightenment tech in our religion mod's cost scales based on the amount of generated piety, so while you are researching it the cost continues to rise. The AI would need to be aware of this cost change otherwise, if it was getting 40 beakers and 40 beakers were being removed from the tech progress each turn, then while the tech would appear to it to take '6 turns' it would in reality be an infinite amount of time, so the AI would just sit there researching it forever always thinking it was only 6 turns away.

If however the price of the tech changed, then by the time the AI got to it, if their piety was too high it would likely already be way too high a cost for the AI to decide to research it in the first place.

yeah if we could change costs, then the AI could handle the decision, which it doesnt do to well anyway. but until then the workaround is to use a whole lot of ifs and use PushReasearch, so pretty much writing a script that takes over the AI's research decision making based off of an informed player's viewpoint, or in other words just taking over the entire AI's tech path with lua :lol:
 
How about unlocking the tech by event instead? You could just make it very expensive so no-one researched it and unlock it via script if certain conditions are fulfilled.
 
How about unlocking the tech by event instead? You could just make it very expensive so no-one researched it and unlock it via script if certain conditions are fulfilled.

Forget "very expensive", you can just turn on the Disabled flag so that it's not possible to research at all.
(Incidentally, how DO you award a specific tech from an event? I need to do exactly that for my own mod.)
 
Forget "very expensive", you can just turn on the Disabled flag so that it's not possible to research at all.
(Incidentally, how DO you award a specific tech from an event? I need to do exactly that for my own mod.)

This, I think:

pTeam:SetHasTech(techID, true);

Can you properly insert disabled techs to the tech tree?
 
I like your thinking. :) What event would we bind it to though? The kind of instrumental point is that if you've been religion heavy, then you're tying up your research for a long period trying to get the Enlightenment, if you could carry on with the tech tree while getting it it would somewhat take away from the point of it.
 
pTeam:SetHasTech(techID, true);

Okay, I'll have to try that. If you've seen my mod at all, one of its key elements is that building the spaceship now is supposed to award you a few things (including a specific tech) when you build it instead of ending the game.

If you know how to do it, I'd appreciate a little LUA coding help on this. (Not to hijack the thread; I'm working on this over in my mod's thread. If I get stuck then I'll start a new thread for this in the LUA forum.)
1> Everyone who builds a spaceship to get a free SP of their choice, a golden age, and the fixed technology Centauri Ecology (not available any other way).
2> The FIRST person to build a spaceship also gets a free tech of their choice, their free golden age lasts twice as long, and they get a permanent +1 UN votes.
3> For 10 turns after the first person builds a ship, the world is at peace. All wars immediately end, and no new ones can start.
4> 10-20 turns after the first spaceship launches, the Barbarians and City-States get Centauri Ecology unlocked as well. (Not sure if this is already covered by the normal Barbarian tech diffusion.)
From what I understand, #1 should be simple, #2 might be a bit tougher, #3 and #4 I have no idea on.

Can you properly add disabled techs to the tech tree then? I think they want you to be able to continue researching techs requiring it?

Who's the "they"? If people want to still be able to research a tech then Disabling is bad, but you were talking about using an event instead of the normal research process.

Disabled techs still show up in the tech tree; they just have a red background to the tech name, a "lock" symbol on the left side of the box, and can't be researched the normal way. Other than that, they look and act exactly like normal techs; they show up in the Civilopedia, for one thing.

But you CAN gain them, and once you have them anything that depends on them will work just fine. For instance, I had Centauri Ecology disabled, but if I started in a later era (where it awards you all earlier techs for free), everything else would progress just fine. That's actually something to be careful of; if you decide to make a special tech in the Renaissance Era, and someone starts a new game in the Industrial, they'll have that tech even if they never built the wonder that you wanted to trigger it; there's no tech equivalent to the "FreeStartEra" building entry.

I'm not sure if you can get one with a Great Scientist, though; I think disabling removes them from all of those lists. But an .lua event like you proposed should work just fine.
 
I like your thinking. :) What event would we bind it to though? The kind of instrumental point is that if you've been religion heavy, then you're tying up your research for a long period trying to get the Enlightenment, if you could carry on with the tech tree while getting it it would somewhat take away from the point of it.

I don't know what you're doing in your mod so I can't comment in any specific way. One possibility would be to simply use a random chance every turn which is influenced by your piety rating (whatever that is, I'm just talking generics here). You could further influence this by creating science buildings and national wonders and certain techs that up your chances. I'm too tired right now to think of more elaborate systems but I'm sure other good options would come to mind.

In short, I would re-interpret the tech so that you will get it at some point but if you're religious, you'll get it much later. In fact, this is a general approach that might be suited to more techs than just enlightenment. The tech tree could be subdivided into chunks you can research where the root tech of each chunk is unlocked by event rather than available for research, or a lot more expensive if you research it normally.

Okay, I'll have to try that. If you've seen my mod at all, one of its key elements is that building the spaceship now is supposed to award you a few things (including a specific tech) when you build it instead of ending the game.

If you know how to do it, I'd appreciate a little LUA coding help on this. (Not to hijack the thread; I'm working on this over in my mod's thread. If I get stuck then I'll start a new thread for this in the LUA forum.)
1> Everyone who builds a spaceship to get a free SP of their choice, a golden age, and the fixed technology Centauri Ecology (not available any other way).
2> The FIRST person to build a spaceship also gets a free tech of their choice, their free golden age lasts twice as long, and they get a permanent +1 UN votes.
3> For 10 turns after the first person builds a ship, the world is at peace. All wars immediately end, and no new ones can start.
4> 10-20 turns after the first spaceship launches, the Barbarians and City-States get Centauri Ecology unlocked as well. (Not sure if this is already covered by the normal Barbarian tech diffusion.)
From what I understand, #1 should be simple, #2 might be a bit tougher, #3 and #4 I have no idea on.



Who's the "they"? If people want to still be able to research a tech then Disabling is bad, but you were talking about using an event instead of the normal research process.

Disabled techs still show up in the tech tree; they just have a red background to the tech name, a "lock" symbol on the left side of the box, and can't be researched the normal way. Other than that, they look and act exactly like normal techs; they show up in the Civilopedia, for one thing.

But you CAN gain them, and once you have them anything that depends on them will work just fine. For instance, I had Centauri Ecology disabled, but if I started in a later era (where it awards you all earlier techs for free), everything else would progress just fine. That's actually something to be careful of; if you decide to make a special tech in the Renaissance Era, and someone starts a new game in the Industrial, they'll have that tech even if they never built the wonder that you wanted to trigger it; there's no tech equivalent to the "FreeStartEra" building entry.

I'm not sure if you can get one with a Great Scientist, though; I think disabling removes them from all of those lists. But an .lua event like you proposed should work just fine.

This is what I wanted to know. Disabling it might work well, in that case.

I'm not experienced in coding Lua for this game so I'd have to spend a significant amount of time on figuring out things if I tried to help you. I hope you understand that I'd rather spend time on figuring out my own stuff ;)
 
Bump.

So lemmy, does your method of adding a UpdateDatabase event work for techs? If so, you could create custom versions of the tech for each civ and make only one of them researchable, then use OR requirements to hook them up to the rest of the tech tree.
 
I got the spaceship-awarded tech working in my game, and that made me think about this question again.

As I said before, one problem is that any game starting in a later era would automatically award all of the earlier techs. So if you wanted each civ to have a unique starting tech, then even a Classical start would give you the full set.

But there's a really crude way around this, I think: create a LUA event that activates when you first start a game (or possibly at the start of each turn, depending on how it works). In that event, manually flag as unresearched all of the "OR" techs other than the one appropriate to your civ (and remember to do the same for the AI civs). The only question would be whether the game would retry awarding them to you at the start of each turn.

And for reference: Disable works just fine. You can't use a Great Scientist or wonder to grab the technology, you can't get it from a Research Agreement, etc., but you can still make a LUA event award it and the game will run correctly from that point.
 
Top Bottom