Simple Python Things

Sure, but this promotion is not a standard one ;).
The python effect is directly applied after promoting, and only to this specific unit -> not after upgrading.
I've thought a bit about it, the effect could be attached/the promotion could be removed with a check after onSelectionGroupPushMission/onUnitSelected/onUnitMove, but all that options are not good for the performance :(.

I assume the problem is that there is no onUnitUpgraded callback where you could do the check.

When you upgrade a unit I think it actually creates a new unit of the upgrade type, setting it to have the same promotions. So there is a question that is relevant: Does upgrading a unit cause the onUnitCreated callback to run? (Note that this is a different callback than onUnitBuilt.)
 
I assume the problem is that there is no onUnitUpgraded callback where you could do the check.

Yes, that's the problem :yup:.

When you upgrade a unit I think it actually creates a new unit of the upgrade type, setting it to have the same promotions. So there is a question that is relevant: Does upgrading a unit cause the onUnitCreated callback to run? (Note that this is a different callback than onUnitBuilt.)

Already checked, it isn't triggered :(.
I'll check, if onUnitSetXY is maybe triggered, but i have no big hope :(.
 
Already checked, it isn't triggered :(.

That's unfortunate. Yet another good idea shot down by reality.

The last resort would be one of the once per turn callbacks with a loop through all units, removing promotions that aren't supposed to be there and making the ones that should do something but aren't do what they should do.
 
I can beleive that.

But if the mod used such a callback already, the difference would be very small. For example, Final Frontier already uses onBeginPlayerTurn, so adding the check there would cause only a tiny amount of additional time.

Perhaps better - it looks like onEndPlayerTurn is run even by regular BtS.
 
I thought of making it a bit easier.
If every wonder unit would die, i could just check after every unit is built, if it's a wonder unit -> no specification what unit would be needed.

:blush: i still haven't started, just thought about organization.

I see. That would make it easier, and personally I don't mind if you prefer to do it that way if it would make everything much more easier - though of course I'd still prefer my way. :)

Thanks anyhow. I am patiently awaiting your work. :)
 
I'm sorry, that it took so long cybrxkhan :blush:.

Dying Heroes

Spoiler :


This modcomponent lets you define units, which you want to die after a certain amount of time.
It includes 3 world units, which will die after 8 rounds (they are just examples, to show, how it works).

- Lifetime is set global one time for all units
- Lifetime automatically scales with iTrainPercent from GameSpeedInfos.xml
- You'll get a warning message 5 rounds and one round before the unit dies.
- If a unit dies, you'll get a popup with a text, which you can specify for every unit or it can be a generic one for every unit.
- You can also add specific popups, when a unit dies in combat
- The lifetimes will be restored after loading (will last longer with the global number of units, and with potential dying units)

The modcomp has 6 parts in the CvEventManager, all labeled with "dying heroes".
The parts, which you have to modify, are labeled with "modify this".


Credits for the unit models go to Mechaerik for his Captain America and his Wolverine, and to Robo Magic Man for his Chuck Norris (had not seen the newer version by GarredSidzaka).



I guess, nobody else will have an use for it, but doesn't matter, i've put it in the download database :D.
Also wouldn't call it "simple", it has a bit more than 100 lines of code. I've learned more about python when doing it, was a good experience :). Okay, the "real" python code (not "civ" python) is still not optimal, but i don't care atm :D.
With the new knowledge, i'll be able to redo the "heroic strength" promotion, in both needed ways :).
After that, i'll redo my "respawn promotion", clean up the code and add the AI to it.
 
Excellent! Glad to see that this is out and ready, and congratulations on making it easier to modify. I'm almost done with the Wonders for WoL, so I should be able to play around and test this in a couple of days or so.
 
I just played around with the dying heroes for a while, and it worked very nicely in my mod - I'm still trying to figure out how to work with the text stuff, but that shouldn't be too hard for me.

Anyhow, there is one "issue" - if we could call it one; actually it's more like just a small thing I noticed. The dying heroes works fine in a normal game; however, if I were to go into worldbuilder and create the hero through there (i.e. the hero wasn't built in the city), then the hero doesn't die.

This is not so much a deal, since the hero will die if it was made normally and not through worldbuilder, but this will become an issue if I or anyone else tries to make scenarios based on WoL, because then the heroes placed in worldbuilding will be immortal.

Is there any way to go around this? This is not too pressing a matter, and it doesn't even need to be solved soon at all, but it is something that caught my attention.

Thanks for your work, anyways, I really appreciate it! :D
 
Good to hear, that it works :).

And i know, it doesn't work with the worldbuilder, because i add the hero to the list after onUnitBuild -> the unit has to be built. I've also tried onUnitCreated, because i thought, this would include the worldbuilder, but it doesn't :(.

But it shouldn't affect scenarios, only if the start in round 0 in the year -4000. If they don't, the game should restore the values after loading it. I say "should", because i'm not sure, if a unit, which is set via worldbuilder, has a value for getGameTurnCreated ().


If you cheat a hero with the worldbuilder for the normal game...okay, then you've cheated a bit more than you've thought :D.
 
I had a weird idea for a function I could use. Hear me out:

A building (which may or may not be a Wonder) is automatically created in a random city anywhere on the map. At the end of the turn it is removed from the city and is created in another random city. This function continues throughout the game, irregardless of any player's action.

Theoretically, is this doable?
 
Water

Spoiler :


This small modcomp adds an improvement (well), which will add fresh water to the plot and the surrounding ones, and gives the same effect to aquaeducts.
The effect is done through an invisible feature, which is generated after building the improvement/building. Sorry, no better way to do it :blush:.

The AI is not aware off this effect, but the values for the well will prevent spawning it, but there's a good chance, that the AI will use it, if there's really bad terrain.

There are 4 changes in the CvEventManager, all labeled with "water".

The modcomp was originally requested by -sr.

The improvement graphic for the well is from here. It was created by woodelf.



To say it here: The Dune Wars mod uses the same system for water, and i in my mod only the water in cities. I didn't really copy it, i've all done by myself, bu the idea was also developed there.



-----------------------------------------------------------


Circus Hagenbeck

Spoiler :


This modcomponent adds the building "Circus Hagenbeck" to the game.
The circus can't be build, it will automatically appear after the year 1890, and move to another random city every third round.

There are 3 changes in the CvEventManager, all labeled with "Circus Hagenbeck".

This modcomp is only able to handle one instance of a building, not multiple ones.
If you need such a thing, please ask.


The model for the circus can be found here and was made by C.Roland.




I've been faster than you, cfkane :D.
I've made the building a national wonder, just because the message, that the worldwonder has been built somewhere, gets annoying after some time.

I wanted to use the Circus Krone, the biggest circus in europe, but i had to find out, that there's no wikipedia article in english for it. Couldn't believe it :gripe:.



------------------------------------------------------------------

Obsolete Corporations

Spoiler :


This modcomp lets corporations go obsolete.
Just add an obsolete tech to the corporations headquarter, and when you research the technology, the corporation will be erased from your cities.
- The corporation will also be deleted, when you capture a city with it
- It'll also be removed, when an executive spreads it again in your cities.

Only problem: You can't prevent, that the AI will try to spread the corporation again in your country -> the AI will still use gold for spreading and production for CEOs, also when it will not have any use in a country.



There are 3 parts in the CvEventManager, all labeled with "obsolete corporations".
In the python code nothing has to be changed, it will all work automatically. Only add an obsolete technology to the corporation headquarter.

I've modified Cereal Mills in this modcomp, so that it goes obsolete with genetics, just to give an example.

The code itself is not very performant, but doesn't matter, because onTechAcquired, onCityAcquiredAndKept and onCorporationSpread are not called sooo often.


This modcomp was originally requested by Kathy.







So, next thing to do, is to do the heroic strenght promotion again (...again), and the request by ripple.
 
Wow. A triple play.

Spiffy.

Does the well allow adjacent tiles to have farms that are considered irrigated? (Giving +1 :food: to a farm on wheat, for example.)

So, next thing to do, is to do the heroic strenght promotion again (...again)

Are you sure you're not stuck in an infinite loop?
 
Thanks for the wonder! I hadn't considered that it could be applied to a traveling circus, but I like the idea nonetheless.

One thing, the building that I had in mind would be around from turn one and move to a different city after one turn. Is it easy to adjust these settings in the code?
 
Another great job, very easy to merge and very good i will also take the Water Well since it fits into my medieval age mod. Thank you very much The_J for your great work!
 
Thanks for the wonder! I hadn't considered that it could be applied to a traveling circus, but I like the idea nonetheless.

It was the only thing, which could imagine to fit in there.

One thing, the building that I had in mind would be around from turn one and move to a different city after one turn. Is it easy to adjust these settings in the code?

I thought, that every round would not add a big effect to the city, so i took 3.

And it's easy to change ;).
The first line in part 3:

PHP:
if (CyGame().getTurnYear(iGameTurn)>=1890) and ( iGameTurn % 3 ==0 ):

The first is the year, the second is the number of rounds between the change. Set iGameTurn %1==0 to let it change every round.


Another great job, very easy to merge and very good i will also take the Water Well since it fits into my medieval age mod. Thank you very much The_J for your great work!

Thanks :).
Good to hear, that somebody else can use it.

FlyingPig commented on the download, that tsentom has done a wonder with that effect, and he's right. I didn't think of that wonder.




:cry: i tried to redo the heroic strength promotion, and it doesn't work.
I've tried to do the same, like in the dying heroes modcomp: Save the player id and the unit id in a global list, and cycle after every round through that list, and apply the bonus, if necessary. But the unit id changes, when you upgrade an unit :mad:.
After that, i've seen, that onUnitCreated and onUnitSetXY have to be activated in the PythonCallbackDefines.xml, so i thought, that this was the reason, why it didn't work the last time...okay, it was sure a part, but both functions are still not called :mad:.
After that, i've tried onUnitSelected. That works...but only for the human player, and not for the AI :mad:
How i hate that :gripe:.


And i've also tried to let religions go obsolete, but when you add a obsolete technology to the religious wonder, that technology doesn't show up in the civilopedia entry of the wonder, and it doesn't go obsolete with it :mad:.
 
Wow. Circus Hagenbeck is excellent. I downloaded
Thanks.
I hope I can manage paste code by right style. My python unexperience cause many errors when I pasted some from codes :(
 
Top Bottom