help! how make marines carry boats?

fahrenderfisch

Chieftain
Joined
Jun 4, 2008
Messages
38
Location
Freiberg
Hi
I'm quite new at modding. So far only played around with the Unitinfo.xml.

Now I wanted to create my first new Unit.
I imagined a small/lightweight/inflatable Boat, which can be carried by Marines in order to increase their amphibious abilitys.
The Graphik does not really look good (just a changed .dds from a workboat and made the zoom smaller), but first I want it to work!

I gave the workboat:
Code:
<SpecialCargo>SPECIALUNIT_PEOPLE</SpecialCargo>
<DomainCargo>DOMAIN_LAND</DomainCargo>
<iCargo>1</iCargo>
Named it SBOAT and made the Marine to a SPECIALUNIT_PEOPLE (just for testing)
So far it works, the sboat can carry one marine along the coast.

Now the Problem:
doing so the other way round, does not work.
I created a SPECIALUNIT_SBOAT
Spoiler :

a copy of SPECIALUNIT_LAND
(I know the AI would probably not use it, I could need a UNITAI_CARRIER_LAND or so)
Code:
<SpecialUnitInfo>
			<Type>SPECIALUNIT_SBOAT</Type>
			<Description>TXT_KEY_UNIT_SBOAT</Description>
			<bValid>1</bValid>
			<bCityLoad>0</bCityLoad>
			<CarrierUnitAIs>
				<CarrierUnitAI>
					<UnitAIType>UNITAI_CARRIER_SEA</UnitAIType>
					<bUnitAI>1</bUnitAI>
				</CarrierUnitAI>
			</CarrierUnitAIs>
			<ProductionTraits/>
		</SpecialUnitInfo>[/SPOILER]

and gave the
Marine:
Code:
<SpecialCargo>SPECIALUNIT_SBOAT</SpecialCargo>
<DomainCargo>DOMAIN_SEA</DomainCargo>
<iCargo>1</iCargo>
The Boat cannot move onto the Tile the Marine is onto (Like Land Units do, entering a boat)

Did I miss something?
Do I have to change the Python scripts somewhere? (by now I do not know how, but I want to learn it anyway)
If yes: WHERE?
Please Help, I got so many more Ideas concerning modern networked and asymetric warfare, but when I can't even do this...:cry:
 
You are only going to be able to load your boat onto your marine if the marine is in a coastal fort or a coastal city. Otherwise the boat will not be able to move onto the land square your marine is in. The only way to fix this is with some really hacky python work, that would probly be to laggy anyway, or you will have to mod the SDK.
 
Is it easyier to modify SDK/Python (dont know where) in a way, so that Graphik changes, when a Marine moves onto a water tile?
 
Ok, I found a bit of code in the SDK (cvUnit.cpp) that seems to regulate the loading on transport vessels.
But since i can't find anything that allows landunits to move on watertiles when there is a transport vessel, there must be somewhere else anything that does this. (or I missed something in the code, only had a real basic C+ course)

Spoiler :

I inserted a bit at the schouldLoadOnMove,
Code:
case DOMAIN_SEA:
		if (pPlot->isCoastalLand())
		{
			return true;
		}
		break;
thought that sounds simillar to what I'm looking for, but it's not working...



Code:
bool CvUnit::canLoadUnit(const CvUnit* pUnit, const CvPlot* pPlot) const
{
	FAssert(pUnit != NULL);
	FAssert(pPlot != NULL);

	if (pUnit == this)
	{
		return false;
	}

	if (pUnit->getTeam() != getTeam())
	{
		return false;
	}

	if (getCargo() > 0)
	{
		return false;
	}

	if (pUnit->isCargo())
	{
		return false;
	}

	if (!(pUnit->cargoSpaceAvailable(getSpecialUnitType(), getDomainType())))
	{
		return false;
	}

	if (!(pUnit->atPlot(pPlot)))
	{
		return false;
	}

	if (!m_pUnitInfo->isHiddenNationality() && pUnit->getUnitInfo().isHiddenNationality())
	{
		return false;
	}

	return true;
}


void CvUnit::loadUnit(CvUnit* pUnit)
{
	if (!canLoadUnit(pUnit, plot()))
	{
		return;
	}

	setTransportUnit(pUnit);
}

bool CvUnit::shouldLoadOnMove(const CvPlot* pPlot) const
{
	if (isCargo())
	{
		return false;
	}

	switch (getDomainType())
	{
	case DOMAIN_LAND:
		if (pPlot->isWater())
		{
			return true;
		}
		break;

	
	case DOMAIN_AIR:
		if (!pPlot->isFriendlyCity(*this, true))
		{
			return true;
		}

		if (m_pUnitInfo->getAirUnitCap() > 0)
		{
			if (pPlot->airUnitSpaceAvailable(getTeam()) <= 0)
			{
				return true;
			}
		}
		break;
	default:
		break;
	}

	if (m_pUnitInfo->getTerrainImpassable(pPlot->getTerrainType())) 
	{ 
		TechTypes eTech = (TechTypes)m_pUnitInfo->getTerrainPassableTech(pPlot->getTerrainType()); 
		if (NO_TECH == eTech || !GET_TEAM(getTeam()).isHasTech(eTech)) 
		{ 
			return true; 
		} 
	} 

	return false;
}


bool CvUnit::canLoad(const CvPlot* pPlot) const
{
	PROFILE_FUNC();

	FAssert(pPlot != NULL);

	if (NO_SPECIALUNIT != getSpecialUnitType())
	{
		if (GC.getSpecialUnitInfo(getSpecialUnitType()).isCityLoad())
		{
			if (!pPlot->isCity(true, getTeam()))
			{
				return false;
			}
		}
	}

	CLLNode<IDInfo>* pUnitNode = pPlot->headUnitNode();
	while (pUnitNode != NULL)
	{
		CvUnit* pLoopUnit = ::getUnit(pUnitNode->m_data);
		pUnitNode = pPlot->nextUnitNode(pUnitNode);

		if (canLoadUnit(pLoopUnit, pPlot))
		{
			return true;
		}
	}

	return false;
}


void CvUnit::load()
{
	CLLNode<IDInfo>* pUnitNode;
	CvUnit* pLoopUnit;
	CvPlot* pPlot;
	int iPass;

	if (!canLoad(plot()))
	{
		return;
	}

	pPlot = plot();

	for (iPass = 0; iPass < 2; iPass++)
	{
		pUnitNode = pPlot->headUnitNode();

		while (pUnitNode != NULL)
		{
			pLoopUnit = ::getUnit(pUnitNode->m_data);
			pUnitNode = pPlot->nextUnitNode(pUnitNode);

			if (canLoadUnit(pLoopUnit, pPlot))
			{
				if ((iPass == 0) ? (pLoopUnit->getOwnerINLINE() == getOwnerINLINE()) : (pLoopUnit->getTeam() == getTeam()))
				{
					setTransportUnit(pLoopUnit);
					break;
				}
			}
		}

		if (isCargo())
		{
			break;
		}
	}
}

Anyone got an idea where I can find that funktion? (allowing landunits to move on water tiles with transport vessel) If I see this code I hope I can copy it and rewrite it so that waterunits can move onto land tiles when there is a transport vessel.

maybe I first have to learn some more C++ (I hoped I would learn it while modding Civ IV)

I would be really thankful for any hints. I've already searched the whole Forum for a kind of SDK Documentation, but the most promissing thing, a wiki, seems to be dead...
 
I would think you should look in CvUnit.cpp canMoveInto. Look for the part in there where it lets sea units move into coastal cities, should be pretty easy to put somthing there that will do what you want.
 
yeah, that sounded like a good idea.
thanks for that hint, Jeckel, but something I'm still doing wrong.
Sorry for me beeing such a dumb...

i've tried differnet things, searched again through the forum and through the sdk, but still have no clue.

canMoveInto starts at line 2247 in original cvUnit.cpp
Code that allows boats entering citys:
Spoiler :
Code:
	case DOMAIN_SEA:
		if (!pPlot->isWater() && !canMoveAllTerrain())
		{
                 //original code
				if (!pPlot->isFriendlyCity(*this, true) || !pPlot->isCoastalLand()) 

//STARTCHANGE 
		//change 1 - boat can still move into own city, but not onto marine's tile
				//if (!pPlot->isCoastalLand())


		//change 2 - boat can neither enter a city nor marine's tile
				//if (!pPlot->isUnit() || !pPlot->isCoastalLand())

		
		//change 4 - neither
				//if (!pPlot->isUnit())


		//change 5 - neither
				//if (!pPlot->isFlatlands())


		//changes 6-9 - copied from Landunits, and changed "isWater"
				//if (bIgnoreLoad || !isHuman() || plot()->isCoastalLand() || !canLoad(pPlot))
				//if (bIgnoreLoad || !isHuman() || plot()->isFlatlands() || !canLoad(pPlot))
				//if (bIgnoreLoad || !isHuman() || !canLoad(pPlot))
				//if (!canLoad(pPlot))

//ENDCHANGE 
				{
					return false;
				}
		}
		break;
Finally I tried it without condition, giving me always "true", the boat could enter the city, but not the marine's tile. somehere i oversee some code...

I just can't figure it out. I thought it is the right part of the code, because "//-ing" it disables ships to move in citys and land units to move onto naval transport vessels.

I've also rechecked the DOMAIN_ and SPECIALUNIT_ tags in the xml's they are as described in post 1, and like Jeckel said, in a city the marine can just pick up the boat and go with it over land...

cvUnit::shouldloadonmove has no influence, "//-ing" it landunits still can move on naval transport

cvPlot::isValidDomainForAction I "//" all behind DOMAIN_SEA so it looks like DOMAIN_LAND, still not working
 
disabled Python Callback, still not working
 
I feel your flustration. This is a hard function to work with. The problem is that the code of the function is looking for situtations to return false. Unfortunatly I can't give you a simple code block to fix your problem.

If you don't have any code in the python unitCannotMoveInto callback then have it enabled or disabled shouldn't make a difference. It just comes down to that sea units wern't "ment" to go into land tiles and making them do it will take some changes.

Don't know what version of civ you are using, but if its BtS you might want to try and see how they allow ships to move into coastal fort tiles.
 
It's BTS with Patch 3.13
I know how they allow ships to move into coastal Citys or Forts, it's the "isCoastalLand" thing. problem is just that it does not work with units.
I also disabled all the code giving me alway True as return, Citys and Forts still were possible, else NONE. It must be a tiny little mistake by me or a bit of code hiding somewhere.

Thank's for your tips and for trying to help and all this so quick.
BUT:
Think I'll do it another way.
Similar like others tried/did it.

I'm thinking about making the Grafik change, like they made it with the "earlyArtDefine"
tag, adding a new tag "amphibWaterArt" so far just had no time to look closer on this.
Have not read of anyone finally made this, but should be possible, eh???

And in the Unitinfo.xml adding an "amphibMoveModifier"
or similar. Maybe even getting some demage (10% per Round ended on water), just dont't know jet how to.

I've read that Kael made his units entering sea tiles, with promotions, have to look closer on that!
Thinkin bout three Promotions:
1 amphib (as it is)
2a sea-amhib can move along coastline (easy, thats what I have now)
2b amhibboardattack chance of boarding enemy ships
(As I know in real a well trained modern Navy Seals Unit can easily take over some of the smaller boats (Destroyers))

and I want new Land Feature: steep coast, so that amphibs (and other Transport) cannot land there.
(for a start maybe just trying to prevent them t land on hills at the coast)
and new Coast (Sea) Improvement built by the workboats: deep Water Channel, so one can make Coastal Water for big Ships impassable, and over the deep Water Channels they still can reach a city. That would make Sea-amphibous Units and small Landing Crafts way more worthfull!
 
Back
Top Bottom