Naval Mines

Mines wouldn't happen to have 2 moves and have their movement managed by a Python function that is run after this one, would they? If it is being placed 1 tile from the city by this function and then the regular mine movement function comes along and moves them 2 you get a total of 3.
 
Mines wouldn't happen to have 2 moves and have their movement managed by a Python function that is run after this one, would they? If it is being placed 1 tile from the city by this function and then the regular mine movement function comes along and moves them 2 you get a total of 3.

Mines have a standard movement of 3 squares set in the XML. So yes that makes sense. My need remains the same. Is there a way to move the mine only 1 of the 3 movements?
 
Ah-ha. I think this is what is happening: the unit has a speed of 3 and you move it the 1 plot to get it out of the city by pushing a move mission that causes it to move 1 plot. This should use up 1 move allowing it to still move 2 more plots later in the turn.

Before you push the mission to move it out of the city, you could set it so that it has only one move left this turn. The move out of the city would use up the movement point so it wouldn't be able to move any more this turn. The other option would be to set it so that it has no more moves this turn and directly change it's position via pUnit.setXY rather than pushing a move mission. Using the mission it should use the normal movement animations if the unit is visible to the player. Directly setting the position makes it jump to the other tile.

To make a unit have only one move left, you should be able to use
Code:
pUnit.setMoves(pUnit.maxMoves()-1)
This ought to leave it with exactly one movement point left.

Note that using "pUnit.maxMoves()-2" won't get you two moves left since moving into a typical ocean tile (or empty flat land tile) actually uses 60 movement points, unless the global definitions are changed for the mod. A unit normally is allowed to move until it uses a number of movement points up to 60 times the iMoves value from the XML. You can get away with the "-1" rather than subtracting the move cost of the target plot because you are allowed to move as long as you have at least 1 point left. You don't have to have enough left to pay the full cost of the plot you are moving into. This is why 1 move units can move onto those 3 cost forest covered hills.
 
To make a unit have only one move left, you should be able to use
Code:
pUnit.setMoves(pUnit.maxMoves()-1)
This ought to leave it with exactly one movement point left.

It worked great! Now I can move on to sending the mine to the best rated plot.

:thanx:

Orion Veteran :cool:
 
OK Mines are moving where I want them. However, I need to tweak the plot rating a bit by obtaining the plot yield value. I'm trying to use the python command:

Code:
if pPlot.getSeaPlotYield(0) > 3:

or

if pPlayer.getSeaPlotYield(0) > 3:

I keep getting errors. How do I fix this line?

Orion Veteran :cool:
 
Because there is no such function. Just try to get the yield the normal way. Ocean plot yields are not calculated any differently than regular land.
 
Because there is no such function.

Hmm.....

Code:
INT getSeaPlotYield (YieldType eIndex)
int (int /*YieldTypes*/) - total YieldType for water plots

Just try to get the yield the normal way. Ocean plot yields are not calculated any differently than regular land.

OK. I'll give that a shot.
 
getSeaPlotYield is used for PLAYERS or CITIES and is only for the lighthouse/Colossus effect. It does NOT return the correct yield from tiles.

Don't get them confused. ;)
 
I'm trying to load two events, from a file called MineWarfareEvents, into the RevDCM Mod (which includes BUG).

I have added this to the init.XML file:

Spoiler :

Code:
	<load mod="Autolog"/>
	<load mod="Reminder"/>  <!-- requires Autolog -->
	<load mod="Civ4lerts"/>
	<load mod="MoreCiv4lerts"/>
	<load mod="Unit Naming"/>
	<load mod="FavoriteCivicDetector"/>
	<load mod="EventSigns"/>
	<load mod="Strategy Overlay"/>
	<load mod="StatusDump"/>
	<load mod="MovieMod"/>
<!--MineWarfare start -->
	[COLOR="red"]<load mod="Mine Warfare"/>[/COLOR]
<!--MineWarfare end-->
<!--RevolutionDCM start - mod components -->
	<load mod="RevDCM"/>
	<load mod="Revolution"/>
<!--RevolutionDCM end-->


I have added this into a file called Mine Warfare.XML file:

Spoiler :

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
	Mine Warfare
	by Orion Veteran
-->
<mod id="Mine Warfare" 
	name="Mine Warfare"
	author="OrionVeteran"
	version="1.0"
	date="04/04/2010"
	url="http://forums.civfanatics.com/showthread.php?t=355343">
	 
	<gameutils module="MineWarfareGameUtils" class="MineWarfareGameUtils"/>
	[COLOR="Red"]<events module="MineWarfareEvents" />[/COLOR]	
</mod>


I have added this to the top of MineWarfareEvents.py file:

Spoiler :

Code:
# Sid Meier's Civilization 4
# Copyright Firaxis Games 2006
# 
# MineWarfareEvents

from CvPythonExtensions import *
import CvUtil
import CvScreensInterface
import CvDebugTools
import CvWBPopups
import PyHelpers
import Popup as PyPopup
import CvCameraControls
import CvTopCivs
import sys
import CvWorldBuilderScreen
import CvAdvisorUtils
import CvTechChooser
import MineWarfare

gc = CyGlobalContext()
localText = CyTranslator()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo


class MineWarfareEvents:
	def __init__(self, eventMgr):	
		self.__LOG_MOVEMENT = 0
		self.__LOG_UNITBUILD = 0
		self.__LOG_UNITBUILD = 0
		self.eventMgr = eventMgr
		
		self.CombatList1 = [
			"UNITCOMBAT_HELICOPTER",
			"UNITCOMBAT_AIR",
			"UNITCOMBAT_MINE_WARFARE"
		]
		
		self.CombatList2 = [
			"UNITCOMBAT_ARMOR",
			"UNITCOMBAT_HELICOPTER",
			"UNITCOMBAT_AIR",
			"UNITCOMBAT_MINE_WARFARE"
		]

		self.MasterMineList = [
			"UNIT_NAVAL_MINE",
			"UNIT_NAVAL_MINE_FIELD",
			"UNIT_NUCLEAR_NAVAL_MINE",
			"UNIT_LAND_MINE",
			"UNIT_LAND_MINE_FIELD",
			"UNIT_NUCLEAR_LAND_MINE"
		]		
		
		self.LandMineList = [
			"UNIT_LAND_MINE",
			"UNIT_LAND_MINE_FIELD",
			"UNIT_NUCLEAR_LAND_MINE"		
		]		
		
		self.NavalMineList = [
			"UNIT_NAVAL_MINE",
			"UNIT_NAVAL_MINE_FIELD",
			"UNIT_NUCLEAR_NAVAL_MINE"		
		]		
		
		self.MineList = [
			"UNIT_NAVAL_MINE",
			"UNIT_LAND_MINE"
		]		
		
		self.MineFieldList = [
			"UNIT_NAVAL_MINE_FIELD",
			"UNIT_LAND_MINE_FIELD"
		]	
	
		self.NuclearMineList = [
			"UNIT_NUCLEAR_NAVAL_MINE",
			"UNIT_NUCLEAR_LAND_MINE"
		]		

		self.SweeperList = [
			"UNIT_NAVAL_MINE_SWEEPER",
			"UNIT_LAND_MINE_SWEEPER"
		]
				
		eventMgr.addEventHandler("UnitMove", self.onUnitMove)
		eventMgr.addEventHandler("UnitBuilt", self.onUnitBuilt)


I have placed the following lines repectively in my events, onUnitMove and onUnitBuilt, at the very beginning of each event to insure the these events work.

Spoiler :

Code:
CyInterface().addImmediateMessage("A" , "")

and

CyInterface().addImmediateMessage("B" , "")


Neither message comes up and it appears the MineWarfareEvents.py file is not loading correctly.

Question: What do I need to do to get these events to work?


Orion Veteran :cool:
 
The mod's ID in the XML must not contain spaces as this is used to name a Python variable. You should see an error to this effect in Logs/PythonErr.log. Change this line

Code:
<mod id="Mine Warfare"

to this

Code:
<mod id="[B]MineWarfare[/B]"
 
The mod's ID in the XML must not contain spaces as this is used to name a Python variable. You should see an error to this effect in Logs/PythonErr.log. Change this line

Code:
<mod id="Mine Warfare"

to this

Code:
<mod id="[B]MineWarfare[/B]"

Made the change, started a new test game and the problem persists. The test was for the onUnitMove, which failed. I did a search in all the error logs for MineWarfareEvents, which failed to appear anywhere.

Edit: I also changed this:

Spoiler :

Code:
<events module="MineWarfareEvents" />
to this:
Code:
<events module="MineWarfareEvents"/>


Removing the space made no difference. :confused:
 
1. Turn on debug logging if you haven't already (see Troubleshooting page in my sig).
2. Run your game to the point you expect the event.
3. Post PythonDbg.log and PythonErr.log. These are the only two files that ever matter for Python stuff. PythonErr2.log is a less-interesting version of PythonDbg.log (go figure).
 
1. Turn on debug logging if you haven't already (see Troubleshooting page in my sig).
2. Run your game to the point you expect the event.
3. Post PythonDbg.log and PythonErr.log. These are the only two files that ever matter for Python stuff. PythonErr2.log is a less-interesting version of PythonDbg.log (go figure).

Will do. I'll post it by 10:00AM in the morning. Must go for now.
 
Here are the log files.

Since PythonErr was empty, I included PythonErr2.

This was a RevDCM game. I opened world builder and placed 3 enemy Naval Mines off the coast and gave myself 3 MineSweepers. When I move one of the Minesweepers onto a plot that I know has an enemy mine, I'm supposed to get a warning sound produced by the function onUnitMove in the MineWarfareEvents.py file. The message failed and no warning sound occurred. Yet, If I play the standard version of this mod, no BUG and no Rev DCM; just a stand alone mod, the function works perfectly in CvEventManager.py.


Orion Veteran :cool:
 

Attachments

BUG cannot find your Mine Warfare.xml file. From PythonDbg.log:

Code:
08:06:15 DEBUG: BugConfig - loading mod file Mine Warfare
08:06:15 DEBUG: BugPath - not a file: 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\RevolutionDCM\Assets\Config\Mine Warfare.xml'
08:06:15 DEBUG: BugPath - not a file: 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Assets\Config\Mine Warfare.xml'
08:06:15 WARN : BugPath - cannot find asset file Mine Warfare.xml in Config
08:06:15 ERROR: BugInit - cannot find XML file for mod Mine Warfare

Where do you have that file? It must be in the Assets/Config folder.

Also, I see that MineWarfareGameUtils.py is being loaded, but not by BUG. That concerns me as I suspect you may have replaced BugGameUtils in CvGameInterfaceFile.py with your own (though maybe you're loading it manually for other reasons which may be okay). If so, this will break other aspects of BUG. Look at the tutorial in my sig for details on the correct way to add your GameUtils callbacks.
 
BUG cannot find your Mine Warfare.xml file. From PythonDbg.log:

Code:
08:06:15 DEBUG: BugConfig - loading mod file Mine Warfare
08:06:15 DEBUG: BugPath - not a file: 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\RevolutionDCM\Assets\Config\Mine Warfare.xml'
08:06:15 DEBUG: BugPath - not a file: 'C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Assets\Config\Mine Warfare.xml'
08:06:15 WARN : BugPath - cannot find asset file Mine Warfare.xml in Config
08:06:15 ERROR: BugInit - cannot find XML file for mod Mine Warfare

Where do you have that file? It must be in the Assets/Config folder.

Also, I see that MineWarfareGameUtils.py is being loaded, but not by BUG. That concerns me as I suspect you may have replaced BugGameUtils in CvGameInterfaceFile.py with your own (though maybe you're loading it manually for other reasons which may be okay). If so, this will break other aspects of BUG. Look at the tutorial in my sig for details on the correct way to add your GameUtils callbacks.

Renamed Mine Warfare.xml to MineWarfare.xml, which currently resides in the Assets/Config folder.

I removed the MineWarfareGameUtils reference.

CvGameInterfaceFile.py has the following:

Code:
import BugGameUtils

GameUtils = BugGameUtils.getDispatcher()

MineWarfare.XML looks like this:

Spoiler :

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
	Mine Warfare
	by Orion Veteran
-->
<mod id="MineWarfare" 
	name="MineWarfare"
	author="OrionVeteran"
	version="1.0"
	date="04/04/2010"
	url="http://forums.civfanatics.com/showthread.php?t=355343">
			
	<gameutils module="MineWarfareGameUtils" class="MineWarfareGameUtils" override="True"/>
	<events module="MineWarfareEvents"/>	
</mod>



Problem with the onUnitMove persists.
 

Attachments

Looks like you have the event keys wrong. Make sure they match the strings in CvEventManager exactly--case included:

Code:
16:27:02 DEBUG: BugEventManager - adding event 'UnitMove'
16:27:02 DEBUG: BugEventManager - adding event 'UnitBuilt'

The above mean that these are new events not seen in BTS. The correct versions start with a lowercase u IIRC, but double-check to be sure.
 
Looks like you have the event keys wrong. Make sure they match the strings in CvEventManager exactly--case included:

Code:
16:27:02 DEBUG: BugEventManager - adding event 'UnitMove'
16:27:02 DEBUG: BugEventManager - adding event 'UnitBuilt'

The above mean that these are new events not seen in BTS. The correct versions start with a lowercase u IIRC, but double-check to be sure.

WOW! It Works! :) :worship:

Orion Veteran :cool:
 
Back
Top Bottom