Simple Python Things

The_J

Say No 2 Net Validations
Administrator
Supporter
Joined
Oct 22, 2008
Messages
39,472
Location
DE/NL/FR
I'm not the greatest python modder, but i can do a bit, and i have some ideas, so i decided to open just one thread for my code parts.



Special thanks to tsentom1, which modcomps are great, and taught me the basics with tsentoms help, and to EmperorFool, who helps to solve the biggest problems.

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

Unit experience through specialists and civics
This modcomp was requested by "Some guy".
Might be unbalanced, but the mechanics can easy be changed.
All changes are labeled with "SpecialistXP".

Spoiler :



The example is with only vassalage as civic. The produced unit has 8 XP (2 through vassalage, 3*2 through the scientists in vasallage.





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

Worldwonder "Monsanto"
It grants you 5 units "Geneticist", who can "plant" the new resource "genetically modified corn", which gives the plot +3/0/2, and 1 :mad: and 1 :health:.
The mechanics are near the same like the pioneer tank below.
All changes are labeled with "Monsanto".
It might be a bit more difficult to understand, but if you have problems, just ask.

No custom art (no need for more files in this small modcomp), and no civilopedia entry (i have writing texts, i'm sorry).
Spoiler :

.







I've re-uploaded the Monsanto-wonder, i've fixed the problem with it.

Problem:
Spoiler :
The problem was, that the AI doesn't understand, that there can be multiple worker units.
It'll just see, that the genetic corn farm doesn't have any tech-prerequisite, and tries to build them everywhere with the normal worker. But you know, normal workers can't build the improvement. So the AI will just not build any improvements on the plots.



Solution:
Spoiler :
I've attached the improvement to a fake technologie. The technologie GEN_CORN is not visibile in the tech treek and can't be researched. After building the wonder, you'll get the technology, but it will not be mentioned, the player will not see it. I've tried to remove the technology after the last improvement was build, but it seems, that it does not work. But shouldn't be a problem at this point of the game.





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

Respawn-Promotion

Requested by cfkane for his Fictionalization IV mod.

Credits: The python is totally based on tsentom1's Survival Promotion. Tsentom has also helped me.
The buttons are from FK2006 (this buttonpack).

Spoiler :











What it does:
I've added 2 new promotions, respawn1+2.
Every promotion gives the unit +1 life.
If the unit dies, the higher respawn-promotion is lost, and the unit is in the capital reborn.
A unit with respawn2 can die, is reborn, loses respawn2, but still has respawn1. If the unit then again dies, it will lose respawn1, but is still reborn. After that, the unit is a normal unit, but can also again get the respawn-promotions.

For modders:
I've added #### Respawn Start ## and ## Respawn End ## in the CvEventManager.py, so you can easy find it.


If yo have any questions, ask me or tsentom1.
(tsentom, i hope, you don't mind it, that i say that)

And give me and tsentom credit, when you use it.


Re-uploaded September, 5th, 6:02 PM forum time.
- Cleaned up the code
- Will now place ships in coastal cities
- Added AI, so that the promotion will be applied to AI-controlled units.

Re-Uploaded September, 8th, 7:40 PM forum time.
- Replaced the button with the new one by Arian (here).

Edit: Re-uploaded on September, 23th, 5:42 PM forum time.
- Fixed a bug, which could lead to an invalid promoting order for the AI. Credits for finding this bug go to EmperorFool

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

Pioneertank
It can create hills and also build forts :).

Spoiler :










3D-modell: Credits to Rabbit, White for his excellent Chimera-Tank.
Python-Code: Credtis to Tsentom1, i took the basics from his Eden Project.


Can be used as it comes as a stand-alone-mod.
Edit: V2 is up, with the changes, tsentom suggested. The AI will maybe know, how to use it.
If you can report some observations of intelligenct ai-use of the pioneer-tank, please report it.


Feel free to use it, but give me credit.


For modders:
Spoiler :

I've added the PIONEERTANK at the end of the UnitInfos.xml and UnitClassInfos.xml., the artdefines at the end of the ArtDefines_Unit.xml.
Also added the improvement CREATE_HILL to the ImprovementInfos.xml, and BUILD_CREATE_HILL to the UnitBuildInfos.xml.
There's an entry in the CIV4ArtDefines_Improvement.xml, but it is not important, it's an dummy, you'll never see it.
Important is change of the CvEventManager.py

Code:
	def onImprovementBuilt(self, argsList):
		'Improvement Built'
		iImprovement, iX, iY = argsList
###PIONEERTANKBEGIN###
		pPlot = CyMap().plot(iX, iY)
		if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_CREATE_HILL'):
		    pPlot.setPlotType(PlotTypes.PLOT_HILLS, True, True)
		    pPlot.setImprovementType(-1)
###PIONEERTANKEND###

It just says: If there's an improvement CREATE_HILL, then change the plot to a hill, and destroy the improvement after it.
Not the most elegant way, but it works.


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

Planetbuster-Rocket
It'll destroy really all in it's catchement area :).

Spoiler :









Uses the ICBM-modell.
Code is from Tsentom1 (his Eden Project), also got much help from him :).
Couldn't have done it without him :).
Also credits to EmperorFool, for his advice :).

Can be used as it comes as a stand-alone-mod.
AI will use it like an ICBM, not like a special unit.


Feel free to use it :), but give me and tsentom1 credit :D.


For modders:
I've added the planetbuster-unitclass and unit at the end of the unitclassinfos.xml and unitinfos.xml
In the CvEventManager.py i've added with tsentom's help this:
Spoiler :

Code:
	def onNukeExplosion(self, argsList):
		'Nuke Explosion'
		pPlot, pNukeUnit = argsList
		CvUtil.pyPrint('Nuke detonated at %d, %d'
			%(pPlot.getX(), pPlot.getY()))
###Planetbusterbegin###		
		if (pNukeUnit is not None and pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_PLANETBUSTER')):

                        
                        iX = pPlot.getX()
                        iY = pPlot.getY()

			for iXLoop in range(iX - 1, iX + 2, 1):
				for iYLoop in range(iY - 1, iY + 2, 1):
						pPlot = CyMap().plot(iXLoop, iYLoop)
						if (( pPlot.isPeak()==true  ) or (pPlot.isHills()==true)):
							pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
 						pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_COAST" ), 1, 1)
###Planetbusterend###

Should be simple to understand. If not, ask me or tsentom :).


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

Palace replacing after conquering capital

In this small modcomp, the human player (NOT the AI) can, after conquering an enemy capital, move his palace to this city.

Spoiler :


There are 3 changes in CvEventManager.py and 1 change in CvScreensInterface.py, all labeled with "moving palace".

This modcomp was requested by cybrxkhan for his mod World of Legends.


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


FixedMPScoreboard

This mod fixes the issue, that you can see in a multiplayer game also the human civs, which you haven't met already.
-> When you start a MP game with this mod, the other human civs should not appear in the scoreboard.

Attention: It was only tested in hot seat.
If it works in normal MP games, then please report it.


There's only 1 change in CvMainInterface, it's labeled with "FixedMPScoreboard".

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


Believer Trait

Image

With this trait, new cities of the leader will automatically have the state religion and the temple of the state religion.

There's only one change in CvEventManager, and it's labeled with "Believer Trait".
Edit: After re-upload there are 2 changes.
2 XML files are included, one for the text, and the CivilizationInfos.xml for an example.

It might be overpowered, but you're free to change it ;).

Edit: Re-uploaded on April, 16th, 4:21 PM forum time
- The effect is now also applied on conquered cities


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

Real Favorite Religion

Spoiler :


In this modcomp, after a religion is founded every leader who has it as favorite religion will automatically get this religion in his capital.

There is only one change in CvEventManager.py, and it's labeled with "real favorite religion".
One XML file with the text for the popup is included.

This modcomp was requested by Caster_Troy


Attention: Makes only real sense with free religion choice .

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

TechTree - New icons and effects

Image

Description:
Spoiler :

In this modcomp, 4 techs get 4 new effects:
  • Constitution: Golden age for everyone who researches it.
  • Music: Golden age for the first player who researches it.
  • Banking: 500*Gamespeed gold for everyone who researches it
  • Fission: Free ICBM for everyone who researches it.

The new effects are only displayed in the tech tree, not in the civilopedia or the hover text.

This mod component has 5 files:
- CvEventManager, for applying the effect
- CvTechChooser, for displaying the icons
- CvGameUtils, for displaying the text when hovering over the icons
- A XML file for the text
- One custom button.

In the python files, search for "TechTree - new icons".

Notes:
- I do not recommend to use or to add any "first player gets" effects to the tech tree, because the AI does not understand the effect and will not try to get the tech first
- To change the effects/icons to a new tech, both CvEventManager and CvTechChooser have to be changed. Changes in one of the files will not automatically be detected.

This modcomp has been requested by Kathy.
 

Attachments

  • Civ4ScreenShot0161.JPG
    Civ4ScreenShot0161.JPG
    85.8 KB · Views: 11,397
  • Civ4ScreenShot0162.JPG
    Civ4ScreenShot0162.JPG
    114.2 KB · Views: 11,319
  • Civ4ScreenShot0163.JPG
    Civ4ScreenShot0163.JPG
    112.5 KB · Views: 11,228
  • Civ4ScreenShot0166.JPG
    Civ4ScreenShot0166.JPG
    117.6 KB · Views: 10,552
  • Civ4ScreenShot0165.JPG
    Civ4ScreenShot0165.JPG
    103.9 KB · Views: 10,483
  • Civ4ScreenShot0164.JPG
    Civ4ScreenShot0164.JPG
    104.7 KB · Views: 11,576
Militia

Spoiler :




Credits:
- The medieval militia is the Pitchforkman by Mechaerik.
- The renaissance militia is the undisciplined minuteman by Bakuel.
- The industrial militia is the Militia Infantry by Mechaerik.
- The modern militia is the Worker Marine by GarretSidzaka.

The last both are similiar, but i had no better idea what to use.

Reuploaded on July, 12th, 05:56 PM

- Fixed to errors, which could appear when the modcomp is altered. Thanks to strategyonly for reporting .

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


Warriors Of God

Spoiler :





Credits:
- The Fanatic is the WarriorMonk by AlazkanAssassin
- The Monk is the Generic Male Missionary by Refar. I've added the knights templar attacking animation with Esemjays KonverterFM. Thanks to Kathy for the idea.


Re-uploaded September, 12th, 5:34 forum time.
- Made the python a lot simpler. You you don't have to change anything :).
- Fixes a bug with the purge religion function from the fanatic.


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


Love And Hate

It allows you to adjust the relations of leaders and civilizations, when they meet each other.
It has two parts in the CvEventManager, both are labeled with "love and hate".
Is probably not very useful for a normal mod, more for a scenario type of mod.


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


Sneak Promotion

Spoiler :



Industry Espionage Promotion

Spoiler :



Like requested by cybrxkhan, i've edited the Marauder Promotion from tsentom1, but changed to espionage and research points.

All changes are labeled with "Sneak"/"Industry Espionage", there are 2 parts in it.
Most important part: I've added a bit AI.
If the AI has a low research rate (<=70%), there's a change, that the "Industry Espionage" will be applied to an unit.
The same with espionage, but with >10% (didn't know a better way :dunno:).

Edit: Re-uploaded Industry Espionage Promotion on September, 10th, 6:12 PM forum time.
Fixes a bug with a wrong variable. Thanks to strategyonly for reporting :).

Edit: Re-uploaded Sneak Promotion at September, 20th, 11:38 AM forum time.
- Corrected a wrong variable in one of the message. The wrong variable caused an exception, and the message was not displayed.

Edit: Re-uploaded all 3 promotions on September, 23th, 5:30-550 PM forum time.
- Fixed a bug, which could lead to an invalid promoting order for the AI.
- Fixed a bug, which could maybe have lead to OOS problems in multiplayer. Credits for finding both bugs go to EmperorFool
- Added the missing messages to the advanced marauder promotion.

Edit: Re-uploaded all promotions on December, 5th, 5:34.39 PM forum time.
- Added new buttons by TheLadiesOgre

Edit: Re-uploaded Sneak promotion on January, 10th, 5:48 PM forum time.
- Fixed the wrong button entry
- Fixed a bug in the espionage points calculation

Edit: Re-uploaded Industry Espionage promotion on February, 27th, 7:15 PM forum time.
- Bugfix: No more error, when the enemy does not research anything
- Bugfix: No more error, when youself do not research anything
- Bugfix: No more research gain when fighting against animals
- Bugfix: Changed possible floating point values, which can't be used, to integer values


Because of that adjustments, i've also modified the original marauder promotion (Marauder Promotion Advanced.).
Will be applied to an unit, if the AI's commerce rate is >=30%, or income per round is <8 Gold.


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


Celebrity Promotion

Spoiler :


The celebrity promotion allows a unit to increase the happiness of a city by 1 :), when it's stationed in it.

All changes are labeled with "celebrity", it has 3 parts.
Part 1: Changes the :) in the city depending on the promotion, and teaches the AI in an simple way, that the unit has to stay for a moment in a city, when the city is unhappy.
Part 2: AI changes, so that the promotion will maybe be applied, when the unit is promoted in an unhappy city.
Part 3: Changes city happiness directly after promoting.

Small bug (i guess; can't be changed): Airlifting a unit with the promotion will not affect the city which airlifts, and the city where the unit arrives.


This modcomp was originally requested by cfkane for his Fictionalization IV Mod.

The button is from ohcrapitsnico, from this button pack.

Edit: Re-uploaded on September, 23th, 5:50 PM forum time.
- Fixed a bug, which could lead to an invalid promoting order for the AI.
- Fixed a bug, which could maybe have lead to OOS problems in multiplayer. Credits for finding both bugs go to EmperorFool
- Added a new button by hrochland

Re-uploaded on October, 9th 2009, 5:21 PM forum time.
- Fixed the typo, thanks to SaibotLieh
- Fixed the bug, that happiness would not be applied to a city, when a unit was build, which had the celebrity promotion as initial promotion.

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


Heroic Strength Promotion

Spoiler :


There are 2 parts in the CvEventManager.py, both labeled with "heroic strength". One part is for the AI (40% chance, that the AI will take the promotion, if available).

The button is by rabbit, white, from this button pack. The original inspiration for this buttons is from the MMORPG Guild Wars.

The inspiration for the name and to take the button is from FfH2.
The promotion was requested by Castor Troy.

Edit: Promotion doesn't work after upgrading the unit :(. Full working dll version is available here.

Edit: Re-uploaded on September, 23th, 5:44 PM forum time.

- Fixed a bug, which could lead to an invalid promoting order for the AI.
- Fixed a bug, which could maybe have lead to OOS problems in multiplayer. Credits for finding both bugs go to EmperorFool
- Added new button by hrochland

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

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".

This modcomp was originally requested by cybrxkhan for his World Of Legends mod.

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).


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

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.


Edit: Re-uploaded September, 5th, 6:04 PM forum time.
- IMPROVEMENT_WELL changed to IMPROVEMENT_WATERWELL (and all references), because WELL collides with the oil well. Thanks to -sr, who reported the bug.

Edit 2: Re-uploaded September, 8th, 7:42 PM forum time.
- Changed the well graphic to the new animated one by hrochland (here).


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


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.

This modcomp is based on an idea by cfkane.


Edit: Re-uploaded on September, 20th, 11:39 AM forum time.
- Added a check, if the city with circus was razed. Thanks to Affores for mentioning.

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

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.

Re-uploaded on October, 11th 2009, 7:08 PM forum time.

- Fixed a bug, which led to the weird effect, that corporations without an obsolete technology directly became obsolete after founding. Thanks to Kathy for finding the bug


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

Wonders destroyed/captured messages

This is a pretty simple interface comfort mod.
When a city with one ore more wonders is captured/destroyed, everybody, who knows the "conquerer", gets a message, that he/she has captured/destroyed these wonders.



There are 2 changes in the CvEventManager, one is labeld with "messages - wonder captured", the another one with "messages - wonder destroyed".

This modcomp was originally requested by Akropolis.


Re-uploaded on Oktober, 9th, 2009, 5:18 PM forum time.

- Changed a variable, which could maybe have lead to wrong results.


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

European Coal And Steel Community

This wonder will, besides the xml effects, add 2 coal and iron resources in the fat cross of the city .

Spoiler :


There's only one change in the CvEventManager, search for "european coal and steel community".

- There are checks for water, impassable terrain and existing resources. If there are not enough plots available, not all resources are placed.

XML: New are only the entries for the building in buildingInfos, buildingClassInfos and artdefines_building, and the text for it.

This modcomp was requested by hrochland.


Edit: Re-uploaded on October, 9th 2009, 5:23.
- Unknown resources will now not more be overwritten. Thanks to TC01, who has mentioned this in his action-button-thread.


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

Real OCC

This modcomp will allow you to play a one city challenge, where also all AI civs can only found one city.

If the occ gameoption is activated, then
- the ability to build settlers is disabled
- and the city founding after the first city also
- and it forces auto razing every city



For modders:
There are 2 changes in the CvGameUtils.py, and one change in the CvEventManager, all labeled with "real occ".
If you merge it, don't forget the XML\PythonCallbackDefines.xml, where the CannotTrain callback has to be set to 1.


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

Real Always War

When you activate the "always war" option in this simple modcomp, then really every civ will be at war with every other civ, and not only with the human player, and they will also not be able to sign peace.


For modders:
There's only a small change in CvEventManager, labeled with "real always war. Nothing more.


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


Spawn A Civ

This modcomp allows you to spawn a civ dynamically triggered by technologies during the game :).

Explanation from my readme:

Spoiler :

Parts of the modcomp:
All files in Assets\Python and Assets\XML\CustomXML\CIV4SpawnCivInfos.xml are parts of this modcomp. All other files belong to the huns civ by cool3a2 and are just in here, to show a good example for a special case.

CvEventManager: There are 4 parts, which have to be merged. All are labeled with "spawn a civ".
(all changes in all python files are labeled like this).
In 2 parts you have to change the path to YOUR MODS CustomXML folder.
For example, the current line is MyFile=open("Mods/SpawnACiv/Assets/XML/CustomXML/CIV4SpawnCivInfos.xml").
If i would merge this in my mod "marsjetzt-v03", i would have to change it to
MyFile=open("Mods/marsjetzt-v03/Assets/XML/CustomXML/CIV4SpawnCivInfos.xml").

SpawnCivUtil: You don't have to change anything here!
(only, if you removed TERRAIN_TUNDRA, TERRAIN_SNOW or TERRAN_DESERT from your mod.
These terrains are named to indicate, which plot is crap for a city. If you have
complete other terrain, then just put in your crappy terrain).

Python\Screens:
The scoreboard and the foreign advisors are changed for the special case of a barbarian civ. These civs should not appear on the scoreboard and in the foreign advisor and this had to be changed. This is just esthetical and is not essential. If you have problems with merging it, then just don't do it.

XML\CustomXML\CIV4SpawnCivInfos.xml: This is a self written file, which is manually loaded my a self written simple XML parser. You can put all your information in here.
There's no schema, so i'll explain it.

<Type>CIVILIZATION_HUNS</Type>: The civilization, which should appear.

<Leader>LEADER_HUNS_Attila</Leader>: The leader for the civ.
Note 1: You can put every leader together with every civ and create nonsense combinations like for example LEADER_ASOKA and CIVILIZATION_SPAIN.
Note 2: If you put in -1 instead of LEADER_XY, the algorithm will choose a random leader from the civ. So if you have CIVILIZATION_AMERICA, you'll get randomly Lincoln, Washington or Roosevelt.

<SpawnTech>TECH_CONSTRUCTION</SpawnTech>: The technology, which spawns the civ.
<NumberOfSpawnTech>3</NumberOfSpawnTech>: So many civs must have the SpawnTech.
Note: If NumberOfSpawnTech is smaller then 1, the first tech will trigger the civ.

<IsBarbarianCiv>True</IsBarbarianCiv>: If set to True, the civ will be at war with
everyone, can't do any diplomacy, is blocked from the foreign advisor and the scoreboard.
Issues:
1) The civ appears in the espionage and the military advisor.
2) You'll get diplomacy bonuses to other civs for having war with this civ.
3) You'll get war weariness for fighting this civ. The war weariness is half of the normal ww.

To make it more clear to the player, that this civ is barbarian,
i suggest that you give the "barbarian" leader the skull button from the barbarians and
add a (barbarian) to civ and leader name.

<StartAtCoast>False</StartAtCoast>: If set to True, all cities will be at the coast.

<TotalGold>100</TotalGold>: With how much gold the civ starts.

<DefaultShips>NONE</DefaultShips>: With what ships the civ starts.
<NumberShipsPerCity>0</NumberShipsPerCity>With how many ships of this type the civ starts.
Notes:
1) -1 and NONE in DefaultShips will give you no ship.
2) only cities at the coast will start with ships.
3) A number below 1 will not produce an error, you'll just get no ship.

<NumberOfCities>2</NumberOfCities>: With how many cities the civ starts.
Note: My city placement algorithm is not very good. It will probably spread the cities
over the whole map, so it's better to let the civ start with a small number of cities.
This will have to be fixed in future versions.

<NumWorkerPerCity>1</NumWorkerPerCity>: How many workers should be in the city.
Note: Worker UUs are not considered here, the civ will start with a normal worker.

<DefaultCityDefender>UNIT_HORSE_ARCHER</DefaultCityDefender>: What units should be in the cities?
<NumberCityDefendersPerCity>4</NumberCityDefendersPerCity>: How many of these units?

Notes:
1) NONE in DefaultCityDefender will give you no units.
2) -1 in DefaultCityDefender will give you the best conscriptable unit which is available for the civ.
(attention: There are no units conscriptable between warrior and rifleman, so if you use that, you should
make some other units conscriptable)
3) A number below 1 in NumberCityDefendersPerCity will not produce an error, you'll just get no units.

<DefaultSecondUnit>-1<DefaultSecondUnit>
<NumberSecondUnit>2</NumberSecondUnit>: Same as above.


Other notes:
1) A typo in the XML file will probably directly lead to a crash and will not produce a python exception
(i don't know why :/ ).
2) The new civ starts with all the technologies from the civ, by which it's triggered.
3) You need a free civ slot to let a civ appear. There's no built in mechanism to kill a civ at the start, so if you start with 18 civs and don't kill one, you'll see no effect.
4) I've added a check for existing civilizations, so that you don't get double civs. CIVILIZATION_RUSSIA will not spawn, if already russia is present in the game.
5) The random leader option doesn't work, if the leader is modular.




Credits:
cool3a2 for the huns civ, and all the artists who have contributed to the civ:
- Ekmek for the animated LH
- Bakuel for unit art, GeoModder and Walter Hawkwood for citystyle
- strategyonly for the files the flag and the button are based on and for finding that horrible bug
- Aranor for the units the tarkan is based on
- Terror666 for the units' sounds

Also credits go to alpha civ for helping me with some basic and essential python things, and to EmperorFool and davidlallen, who have commented on my approaches for reading the xml file via python (which i didn't use in the end...).

Re-uploaded on November, 15th, 3:20 forum time.
- added the tag "SpawnChance" to the XML, so that there's also a chance, that the civ will not spawn. Every value between 0 and 100 is valid. Values under 0 will be treated like 0, values over 100 will be treated like 100.
- added the tags "StartX" and "StartY" to the XML. You can add here a X and a Y coordinate for the first city (only for the first). Attention: There's no check for a valid position. If you want to place a city in water or on a peak, the function will do this. It's only checked, if there's already a city, then the new city will not be placed. Other units on the plot will be moved to a near plot.

Re-uploaded on December, 5th, 4:54 PM forum time.
- Added TechPercent tag, so that a civ can also start with less techs than the civ, which causes the spawn. Every value between 0 and 100 is valid. Values under 0 will be treated like 0, values over 100 will be treated like 100. For example, if you have 15 techs, and the TechPercent is 33, the new civ will 5 techs, which are at the most left in the tech tree. It will not happen, that a civ has an advanced tech, but not an basic tech.

Re-Uploaded on April, 9th, 6:39 AM Forum time.
- added 2 tags, to allow also to add a unit only to the capital and to define the number of it.

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

Ecumenical Council

Spoiler :


Mod parts:
Spoiler :

In CvGameUtils.py is the code for 6 or more religions. Code is labeld with "ecumenical council", only 1 part.
In CvEventManager is the code for the improvement of the relationship, also labeled with "ecumenical council", also only 1 part.

Other parts:
Assets\XML\PythoncallbackDefines.xml to activate the callback in CvGameUtils.

For the buidling: Assets\XML\Buildings\BuildingClassInfos.xml and Buildingsinfos.xml
For the building art: Assets\XML\Art\Structures\Buildings\EcumenicalCoun cil with the art.
Assets\XML\Art\ArtDefines_Buildings.xml to get the art in.
Assets\XML\Text\EcumenicalCouncil_gametext.xml for the text.

No wondermovie available.




The 3D modell is the bampton church by hrochland.

This modcomp was requested by hrochland.



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

Training Obsolte Units

Spoiler :


This small modcomp allows you to build units, even when you are able to build all more advanced units.

It consists only of 2 lines in Assets\Python\CvGameUtils.py, they are labeled with "training obsolete units" (and the activation of the cannotTrain callback in Assets\XML\PythoncallbackDefines.xml).


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


Civilopedia: Invisible dummy techs
Sevopedia: Invisible dummy techs

This small modcomps manipulates the civilopedia in that way, that dummy techs (technologies with X or Y coordinates of 0 or less, so that they don't appear in the tech tree and are normally invisible ingame), don't appear in the tech section of the civilopedia.

All changes are labeled with "invisible dummy tech". There are 2 entries in CvPediaMain and 1 in CvPediaTech. (Sevopedia: 1 change in CvPediaMain)

Note for the sevopedia version: If you want to use this modcomp with the BUG mod, you can't just drag and drop this file, but you can copy the changed code directly to BUG\Assets\Python\Contrib\Sevopedia\SevoPediaMain at the same place.

This modcomp was requested by Cybah for his BASE mod.

Sevopedia version re-uploaded on April, 13th, 3:57 PM forum time.
- Fixed a graphical quirk in in combination with BUG. Thanks to Cybah for reporting and thanks to EmperorFool for the help.



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

Interfaith

This modcomp adds a new project to the game, which will spread immediatly after finishing all found religions to every city of every player (barbarians not included).

Spoiler :


One change in CvEventManager.py, it's labeled with "interfaith".



This effect was requested by cfkane for his Fictionalization mod.
 
Great stuff, the more the better and thx to all, i like stuff thats does not have dll/sdk stuff, so again thx.

:yup:

Nothing better than having a really cool feature that can easily be merged. That's why i stay away from .dll modifications >_>.
 
That Pioneer Tank seems strangely familiar considering I've just been playing Dawn of War... :)
 
That Pioneer Tank seems strangely familiar considering I've just been playing Dawn of War... :)

Look at the original models, where i got it from ;).

Looks cool man! :goodjob: can't wait to see some more. :)

Thanks :).

A second idea has come to my mind, but i do not have the time to program them atm :(.

OK tried the respawn out, and was ok, WHEN playing, but when i tried to go to the Main Menu it crashed to desktop.

I took out just the python portion and re-placed it with the old one and it did NOT crash when i tried to go to the Main Menu?? This was after around 100 turns or more.

:confused: strange.
I haven't experienced a problem like that, and i've tested it several times.
Do you have the logs enabled?
Could you attach one?
 
Militia
Download





Credits:
- The medieval militia is the Pitchforkman by Mechaerik.
- The renaissance militia is the undisciplined minuteman by Bakuel.
- The industrial militia is the Militia Infantry by Mechaerik.
- The modern militia is the Worker Marine by GarretSidzaka.

The last both are similiar, but i had no better idea what to use.

If you use it, give me and the others credit :).




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


Warriors Of God
Download







Credits:
- The Fanatic is the WarriorMonk by AlazkanAssassin
- The Monk is the Generic Male Missionary by Refar. I've added the knights templar attacking animation with Esemjays KonverterFM. Thanks to Kathy for the idea.


Have fun, and give me and the others credit when you use it :).


For modders:
Spoiler :

The python is a bit ugly.
First, in the CvGameUtils there's the restriction to a state religion, not a great deal.
From the 4 effects in the CvEventManager are 2 not very well programmed.
1. XP throug state religion buildings:
I don't know, how to get from the state religion to the buildings, so i used another way.
I have an array with all adjectives of the seven religions in the right order, and to get the buidlings, i make for example building_+"adjective"_temple. So, if you have more than the 7 religions in your mod, make sure, that you add the adjective in the right order to the array, and that you name your religious buildings with this schema. There are also some loops, which need the number of religions, but there's a variable with the proper name.
2. Purging religions when capturing a city:
I also don't know, how to get the unit, which captured a city, so i used onCombatResult. But there's also no easy way to get the combatUnits in the city, so i use GetMilitaryHappinessUnits. If this variable is 1, it means, that it was the last combatUnit in the city (where talking about the combat, so it's before we capture the city), and then i purge the religions (in fact, they are destroyed before city is captured). So if you have a combatunit, which doesn't create military happiness, there's a chance, that the effect doesn't work right.

So, if you have questions, aks me :), i'll try to help
 

Attachments

  • Civ4ScreenShot0023.JPG
    Civ4ScreenShot0023.JPG
    114.8 KB · Views: 9,208
  • Civ4ScreenShot0024.JPG
    Civ4ScreenShot0024.JPG
    117.4 KB · Views: 10,762
  • Civ4ScreenShot0025.JPG
    Civ4ScreenShot0025.JPG
    114.8 KB · Views: 10,795
  • Civ4ScreenShot0179.JPG
    Civ4ScreenShot0179.JPG
    96.9 KB · Views: 10,762
  • Civ4ScreenShot0180.JPG
    Civ4ScreenShot0180.JPG
    121.3 KB · Views: 10,927
So thaat's why you needed the militia units. But i have some questions:
Why did you include 2 pictures of the Monk unit? They both seem to be the same, or am i missing something?

Why didn't you use one of the medieval militia for that time period? Unless you wanted a pitchfork wielding one, but then you could've asked.
 
So thaat's why you needed the militia units.

:yup:

But i have some questions:
Why did you include 2 pictures of the Monk unit? They both seem to be the same, or am i missing something?

Look at the special abilities at the left ;).

Why didn't you use one of the medieval militia for that time period? Unless you wanted a pitchfork wielding one, but then you could've asked.

Yes, i wanted a guy with a pitchfork, because that's what i think is a medieval militia.
Thanks for your offer, but the unit fits very good i think, no need for another one :).
Out of interest: What would you change to make it a medieval one?
 
:yup:



Look at the special abilities at the left ;).



Yes, i wanted a guy with a pitchfork, because that's what i think is a medieval militia.
Thanks for your offer, but the unit fits very good i think, no need for another one :).
Out of interest: What would you change to make it a medieval one?

I tried out the Militia and i like it, i use them to cover my workers now.
 
Thanks, that you let me know it :). Nice, that it is used :dance:.
I've already seen your post in Avains thread, but didn't want to hijack it.



No real projects in the pipeline atm, but i can maybe add some AI to the WarriorsOfGod, i'll have to take a closer look at it :).
 
I have had an idea for a little while now that would be awesome to do but my I'm no good with python.

Basically, I think it would be cool if there was a Recruitment Center building (made available with Assembly Line, Nationalism and Rifling) that, when built, would siphon some of the city's culture and commerce and use it as production towards National Guard units (which would basically be infantry draftees for "free" that could only defend). I was thinking that you'd be limited to a number of National Guard units equal to the number of free units that you'd get for having Serfdom and you'd only be able to recruit them you couldn't actually train them. I was also thinking that if you had the Nationhood civic option they would spawn with experience points equal to the normal amount rather than the watered down draftee starting total.

Just a thought, do you think it's doable?
 
It's a good idea, but it's beyond my abilities :(.

I would have to store the values for the saved "income" somewhere, which i can't atm, and it would maybe a probleme if you're running into a money crisis.
Also i can't see a way to access the recruiting-button via python.

The closest thing, which i could imagine, is to change tsentom's crusaders-wonder, so that it spawns a national guard unit in the city with the highest culture, but this is not what you that of, i guess.
 
I didn't know if it could be done, I don't know much of anything about python. I didn't see it having a button, I saw it more as a set and forget type thing, spawning national guard units until you reached your limit and then stopping. If you lost national guard units, then it would resume generating them. Thanks anyway, I have all sorts of ideas and little know how of implementing them.
 
Top Bottom