Quick Modding Questions Thread

One more quick python thing. I'm trying to make a land mine that's invisible, and have it so that whenever a unit moves into the same space as the land mine, the land mine gets killed and the unit gets damaged.

I put this in onUnitMove in CvEventManager:
Code:
#Land mine
		for i in range(pPlot.getNumUnits()):
			pOtherUnit = pPlot.getUnit(i)
			if pOtherUnit.getUnitType() == gc.getInfoTypeForString('UNIT_LAND_MINE'):
				pOtherUnit.Kill(0,PyPlayer(pOtherUnit.getOwner()))
				iRnd = CyGame().getSorenRandNum(100,"Land Mine")
				pUnit.changeDamage(iRnd,pUnit.getOwner())
But it's not doing anything at all...when I move units into the land mine square they just sit there.
I'm thoroughly stumped...what should I do? :confused:

Just set damage to both units to 100 and you are done. Some example from my mod.

You can found a lots of python examples in my mod and PLAY them, it's very interesting. RECONSTRUCTION THREAD.

And i suggest you to download platyping megapack and gigapack you really can found a lots of examples there and this can help you too CIV 4 PYTHON API :)

Code:
		if pLoser.isHasPromotion(gc.getInfoTypeForString("PROMOTION_HARMONY_POISON")):
			if pWinner.getDamage() >= 80:
				pWinner.setDamage(100, false)
				CyInterface().addMessage(iPlayerWinner,true,10,CyTranslator().getText("TXT_HARMONY_POISON",(pWinner.getName(),)),'',0,'',-1, -1, -1, true,true)
				CyInterface().addMessage(iPlayerLoser,true,10,CyTranslator().getText("TXT_HARMONY_POISON",(pWinner.getName(),)),'',0,'',-1, -1, -1, true,true)
				pPlayerLoser.changeCombatExperience(1)
 
Just set damage to both units to 100 and you are done. Some example from my mod.

Thanks, I tried it (see below), but it's still not doing anything when I move a unit over a land mine.

Code:
for i in range(pPlot.getNumUnits()):
			pOtherUnit = pPlot.getUnit(i)
			if pOtherUnit.getUnitType() == gc.getInfoTypeForString('UNIT_LAND_MINE'):
				pOtherUnit.setDamage(100,false)
				iRnd = CyGame().getSorenRandNum(100,"Land Mine")
				pUnit.setDamage(iRnd, false)
 
Is there a xml file that allows you to edit leader influence/attitude values?

Sent from my SM-G903W using Tapatalk
 
How to I make a wonder disable/block the construction of another particular wonder?
 
How to I make a wonder disable/block the construction of another particular wonder?

You need to use the python call back for "can construct".

First turn it on in the PythonCallbackDefines.XML file found in the Assets\XML folder.

Then code the python, I think Platyping has an example in his code somewhere. I can't find my own example at the moment. It is a function called canConstruct if I remember correctly. Basically if the building wanted to construct is the particular wonder then count the number of the blocker buildings (this is a single call) the player has and if it is not zero return true otherwise return false.
 
Is it safe to assume that the Python call onBeginPlayerTurn happens before onCityDoTurn for each city of the player?

I want a player level test on something happening and if it does then have something possible happen in each of that player's cities.

Further does onBeginGameTurn happen before or after the onBeginPlayerTurn?
 
Is it safe to assume that the Python call onBeginPlayerTurn happens before onCityDoTurn for each city of the player?

I want a player level test on something happening and if it does then have something possible happen in each of that player's cities.
It took some code reading, search and tracing through both cpp and python to figure this one out, but yeah, it does appear that onBeginPlayerTurn happens before onCityDoTurn.

Further does onBeginGameTurn happen before or after the onBeginPlayerTurn?
This one turned out to be even more complex to track, but the same goes. onBeginGameTurn is called before onBeginPlayerTurn.

Be aware that the call order is in the DLL and as such can be changed by a mod. I have no idea why anybody would want to do that, but it's technically possible.
 
It took some code reading, search and tracing through both cpp and python to figure this one out, but yeah, it does appear that onBeginPlayerTurn happens before onCityDoTurn.


This one turned out to be even more complex to track, but the same goes. onBeginGameTurn is called before onBeginPlayerTurn.

Be aware that the call order is in the DLL and as such can be changed by a mod. I have no idea why anybody would want to do that, but it's technically possible.

Thank you. I did a few tests and traces just in Python after posting and got the same results. Confirmation from a dll perspective helps a lot.
 
Actually, this should be simple to understand. BPT is start of each player, while BGT is start of that round. Naturally, BGT has to go before the first player takes his turn.
 
Actually, this should be simple to understand. BPT is start of each player, while BGT is start of that round. Naturally, BGT has to go before the first player takes his turn.
Yeah it's simple to understand and it is as I would have expected and it also matches my initial impression from the code. However my goal was to be able to point to each line in the code relevant to this and from that state the order with 100% accuracy. This is less trivial and the worst part is CvPlayer::doTurn, as it should be called from CvGame::doTurn() if the code follows naming conventions. However the ability to play at the same time in multiplayer makes this specific part of the code somewhat harder to read and CvPlayer::doTurn is surprisingly not even called from CvGame. It involves some stuff regarding setting the player's turn active and in this process doTurn is called from within CvPlayer. AFAIK it's the only class, which calls doTurn on itself.
 
Greetings!

I am trying to create a new type of invisible units - for example I want to make Paratroopers invisible, while giving Gunship detection vs them.

I have examined how Submarine/Destroyer works and I see these tags:

<Invisible>INVISIBLE_SUBMARINE</Invisible>
<SeeInvisible>INVISIBLE_SUBMARINE</SeeInvisible>


Question is - where does INVISIBLE_SUBMARINE determined? how does game knows what to do with it? Can go there and create new invisibility tag for a different type of units?

Thank You!
 
It's entirely possible and I've done it myself. Two other keys you need are <InvisibleInfo> (see Civ4InvisibleInfos.xml [BTS] or Civ4BasicInfos.xml [Vanilla/Warlords] in BasicInfos) and a TXT_KEY_ definition for display in the Civilopedia (Firaxis organizes them in GameText_Objects).
 
Got a new computer, so I may just be forgetting a step

Whenever I put in a debug DLL the mod doesn't load. It doesn't crash or anything, but the mod just never loads. I'm using just the regular debug DLL available on this site. If I remove the DLL, it loads perfectly fine. Any ideas??
 
It's entirely possible and I've done it myself. Two other keys you need are <InvisibleInfo> (see Civ4InvisibleInfos.xml [BTS] or Civ4BasicInfos.xml [Vanilla/Warlords] in BasicInfos) and a TXT_KEY_ definition for display in the Civilopedia (Firaxis organizes them in GameText_Objects).


thank you so much! I think I got it working ! ;)
 
Another question.

About Flank attack.
I have certain units doing Flank attacks vs some Siege units. Problem is that I have many different siege units and listing them all is cumbersome.
So instead of listing Catapult, Trebuchet, Cannon, etc.
I would like just to say: Flank Attack vs Siege units and be done with it.

Any ideas?
Thanks! =)
 
Got a new computer, so I may just be forgetting a step

Whenever I put in a debug DLL the mod doesn't load. It doesn't crash or anything, but the mod just never loads. I'm using just the regular debug DLL available on this site. If I remove the DLL, it loads perfectly fine. Any ideas??
I can't tell why it fails when it used to work, but I can say that I have had really bad luck using debug DLLs compiled by other people. However if I compile them myself, then they work just fine. Considering that a debug DLL is not really useful without the debugger and that the debugger doesn't work unless the compiler works, I have yet to see a good reason to use debug DLLs compiled by other people.

If you aim to get assert messages to test your xml changes, then you should get an assert DLL, not a debug DLL. The difference is that the assert DLL is optimized, and while it's slower than release, it's still much faster than a debug one. Debug is really only for attaching the debugger to keep an eye on what the game does at runtime.
 
I can't tell why it fails when it used to work, but I can say that I have had really bad luck using debug DLLs compiled by other people. However if I compile them myself, then they work just fine. Considering that a debug DLL is not really useful without the debugger and that the debugger doesn't work unless the compiler works, I have yet to see a good reason to use debug DLLs compiled by other people.

If you aim to get assert messages to test your xml changes, then you should get an assert DLL, not a debug DLL. The difference is that the assert DLL is optimized, and while it's slower than release, it's still much faster than a debug one. Debug is really only for attaching the debugger to keep an eye on what the game does at runtime.

Turns out, I can't load any mod with a DLL (just only tried debug since restarting game). Any idea why I wouldn't be allowed to load games with DLLs? I'm actually on the same computer I used to mod on (got a new hard drive so had to reinstall game) so I'm not sure why they won't even load?
 
Turns out, I can't load any mod with a DLL (just only tried debug since restarting game). Any idea why I wouldn't be allowed to load games with DLLs? I'm actually on the same computer I used to mod on (got a new hard drive so had to reinstall game) so I'm not sure why they won't even load?
I think there are two things, which can have happened:

1: civ can't read the DLL
This would be a file permission issue. I can't tell why it accepts other other files and not the DLL if this is the case.

2: some security prevents loading 3rd party DLL files
Steam has some anti hacking/cheating stuff, which prevents using a debugger. Maybe it can even prevent reading the DLL. I recall something about the newest version removing direct IP connection and some mod support. It should be possible to switch to the previous version inside steam.

If you have the disc version, try reinstalling outside program files (like C:\games). That will solve most file permission problems. If it's the steam version, then seek help from somebody with experience with that version.
 
Turns out, I can't load any mod with a DLL (just only tried debug since restarting game). Any idea why I wouldn't be allowed to load games with DLLs? I'm actually on the same computer I used to mod on (got a new hard drive so had to reinstall game) so I'm not sure why they won't even load?

Did you apply the patch to get Civ up to the last version, 3.19 for BtS? The DLL and .exe should match versions, so if the DLL in the mod was build for BtS 3.19 then the game needs to be at 3.19.
 
Top Bottom