Ships sinking in Ocean

Megatherion

Chieftain
Joined
Aug 28, 2004
Messages
65
Location
Germany, Rhine, Loreley
Hi,
this is probably rather easy, but I'm just not getting the desired effect.
I always found it rather stupid that some ships can't enter ocean, so I thought I'd change that, which was easy.
I also wanted to make early ships that enter ocean before navigation is invented to sink (preferably with a 50 or 75% chance).
I've read through the Events tutorial and THOUGHT I found what I wanted, but somehow I don't get the desired effect.
Here's my Civ4EventInfos
Code:
<EventInfo>
			<Type>EVENT_LOSE_IN_OCEAN_1</Type>
			<Description>TXT_KEY_EVENT_LOSE_IN_OCEAN_1</Description>
			<LocalInfoText/>
			<WorldNewsTexts/>
			<OtherPlayerPopup/>
			<QuestFailText/>
			<bQuest>0</bQuest>
			<bGlobal>0</bGlobal>
			<bTeam>0</bTeam>
			<bPickCity>0</bPickCity>
			<bPickOtherPlayerCity>0</bPickOtherPlayerCity>
			<bDeclareWar>0</bDeclareWar>
			<iGold>100</iGold>
			<bGoldToPlayer>0</bGoldToPlayer>
			<iRandomGold>0</iRandomGold>
			<iCulture>0</iCulture>
			<iEspionagePoints>0</iEspionagePoints>
			<bGoldenAge>0</bGoldenAge>
			<iFreeUnitSupport>0</iFreeUnitSupport>
			<iInflationMod>0</iInflationMod>
			<iSpaceProductionMod>0</iSpaceProductionMod>
			<Tech>NONE</Tech>
			<TechFlavors/>
			<iTechPercent>0</iTechPercent>
			<iTechCostPercent>0</iTechCostPercent>
			<iTechMinTurnsLeft>0</iTechMinTurnsLeft>
			<PrereqTech>NONE</PrereqTech>
			<UnitClass>NONE</UnitClass>
			<iNumFreeUnits>0</iNumFreeUnits>
			<bDisbandUnit>1</bDisbandUnit>
			<iUnitExperience>0</iUnitExperience>
			<iUnitImmobileTurns>0</iUnitImmobileTurns>
			<UnitPromotion/>
			<UnitName/>
			<UnitCombatPromotions/>
			<UnitClassPromotions/>
			<BuildingClass>NONE</BuildingClass>
			<iBuildingChange>0</iBuildingChange>
			<BuildingExtraYields/>
			<BuildingExtraCommerces/>
			<BuildingExtraHappies/>
			<BuildingExtraHealths/>
			<iHappy>0</iHappy>
			<iHealth>0</iHealth>
			<iHurryAnger>0</iHurryAnger>
			<iHappyTurns>0</iHappyTurns>
			<iRevoltTurns>0</iRevoltTurns>
			<iMinPillage>0</iMinPillage>
			<iMaxPillage>0</iMaxPillage>
			<iFood>0</iFood>
			<iFoodPercent>0</iFoodPercent>
			<FreeSpecialistCounts/>
			<FeatureType>NONE</FeatureType>
			<iFeatureChange>0</iFeatureChange>
			<ImprovementType>NONE</ImprovementType>
			<iImprovementChange>0</iImprovementChange>
			<BonusType>NONE</BonusType>
			<iBonusChange>0</iBonusChange>
			<RouteType>NONE</RouteType>
			<iRouteChange>0</iRouteChange>
			<BonusRevealed>NONE</BonusRevealed>
			<BonusGift>NONE</BonusGift>
			<PlotExtraYields/>
			<iConvertOwnCities>0</iConvertOwnCities>
			<iConvertOtherCities>0</iConvertOtherCities>
			<iMaxNumReligions>-1</iMaxNumReligions>
			<iOurAttitudeModifier>0</iOurAttitudeModifier>
			<iAttitudeModifier>0</iAttitudeModifier>
			<iTheirEnemyAttitudeModifier>0</iTheirEnemyAttitudeModifier>
			<iPopulationChange>0</iPopulationChange>
			<AdditionalEvents/>
			<EventTimes/>
			<ClearEvents/>
			<PythonCallback/>
			<PythonExpireCheck/>
			<PythonCanDo/>
			<PythonHelp/>
			<Button>,Art/Interface/Buttons/Process/Blank.dds,Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,8,5</Button>
			<iAIValue>1000</iAIValue>
		</EventInfo>
As far as I get it, I don't do much in here except activating bDisbandUnit, while the EventTrigger should determine which Unit is affected. I tried specifying a Unit in here, but the popup would then tell me that I recieve 0 Galleys and lose the unit.

And this is Civ4EventTriggerInfos

Code:
<EventTriggerInfo>
			<Type>EVENTTRIGGER_LOSE_IN_OCEAN</Type>
			<WorldNewsTexts>
				<Text>TXT_KEY_EVENTTRIGGER_LOSE_IN_OCEAN</Text>
			</WorldNewsTexts>
			<TriggerTexts>
				<TriggerText>
					<Text>TXT_KEY_EVENT_TRIGGER_LOSE_IN_OCEAN_1</Text>
					<Era>NONE</Era>
				</TriggerText>
			</TriggerTexts>
			<bSinglePlayer>0</bSinglePlayer>
			<iPercentGamesActive>100</iPercentGamesActive>
			<iWeight>-1</iWeight>
			<bProbabilityUnitMultiply>0</bProbabilityUnitMultiply>
			<bProbabilityBuildingMultiply>0</bProbabilityBuildingMultiply>
			<Civic>NONE</Civic>
			<iMinTreasury>0</iMinTreasury>
			<iMinPopulation>0</iMinPopulation>
			<iMaxPopulation>0</iMaxPopulation>
			<iMinMapLandmass>0</iMinMapLandmass>
			<iMinOurLandmass>0</iMinOurLandmass>
			<iMaxOurLandmass>-1</iMaxOurLandmass>
			<MinDifficulty>NONE</MinDifficulty>
			<iAngry>0</iAngry>
			<iUnhealthy>0</iUnhealthy>
			<UnitsRequired>
				<UnitClass>UNITCLASS_GALLEY</UnitClass>
			</UnitsRequired>
			<iNumUnits>0</iNumUnits>
			<iNumUnitsGlobal>0</iNumUnitsGlobal>
			<iUnitDamagedWeight>0</iUnitDamagedWeight>
			<iUnitDistanceWeight>0</iUnitDistanceWeight>
			<iUnitExperienceWeight>0</iUnitExperienceWeight>
			<bUnitsOnPlot>1</bUnitsOnPlot>
			<BuildingsRequired/>
			<iNumBuildings>0</iNumBuildings>
			<iNumBuildingsGlobal>0</iNumBuildingsGlobal>
			<iNumPlotsRequired>0</iNumPlotsRequired>
			<bOwnPlot>0</bOwnPlot>
			<iPlotType>-1</iPlotType>
			<FeaturesRequired/>
			<TerrainsRequired>
				<TerrainType>TERRAIN_OCEAN</TerrainType> 
			</TerrainsRequired>
			<ImprovementsRequired/>
			<BonusesRequired/>
			<RoutesRequired/>
			<ReligionsRequired/>
			<iNumReligions>0</iNumReligions>
			<CorporationsRequired/>
			<iNumCorporations>0</iNumCorporations>
			<bPickReligion>0</bPickReligion>
			<bStateReligion>0</bStateReligion>
			<bHolyCity>0</bHolyCity>
			<bPickCorporation>0</bPickCorporation>
			<bHeadquarters>0</bHeadquarters>
			<Events>
				<Event>EVENT_LOSE_IN_OCEAN_1</Event>
			</Events>
			<PrereqEvents/>
			<bPrereqEventPlot>0</bPrereqEventPlot>
			<OrPreReqs/>
			<AndPreReqs/>
			<ObsoleteTechs/>
			<bRecurring>1</bRecurring>
			<bTeam>0</bTeam>
			<bGlobal>0</bGlobal>
			<bPickPlayer>0</bPickPlayer>
			<bOtherPlayerWar>0</bOtherPlayerWar>
			<bOtherPlayerHasReligion>0</bOtherPlayerHasReligion>
			<bOtherPlayerHasOtherReligion>0</bOtherPlayerHasOtherReligion>
			<bOtherPlayerAI>0</bOtherPlayerAI>
			<iOtherPlayerShareBorders>0</iOtherPlayerShareBorders>
			<OtherPlayerHasTech>NONE</OtherPlayerHasTech>
			<bPickCity>0</bPickCity>
			<bPickOtherPlayerCity>0</bPickOtherPlayerCity>
			<bShowPlot>1</bShowPlot>
			<iCityFoodWeight>0</iCityFoodWeight>
			<PythonCanDo/>
			<PythonCanDoCity/>
			<PythonCanDoUnit/>
			<PythonCallback/>
		</EventTriggerInfo>
I'm a bit at a loss here. I thought it was quite straight-forward, but other than getting the event triggered, I had no success. And it triggers always, not only when my galley is on ocean. On the other hand, I don't lose the galley.
So, could you point me to my mistake?
Thanks
 
Ah, well... sometimes posting is all it needs. I found the culprit. Hadn't set <iNumUnits></iNumUnits> to 1.
:facepalm:

Edit:
Werrrll... still not there.
Now I seem to be able to let them sink no matter if they're on ocean or coast. Furthermore, when I set the iWeight to -1 so that the trigger is active every turn, only one ship will be affected.
Where am I going wrong?
 
Now I seem to be able to let them sink no matter if they're on ocean or coast.

Probably a night very specific implementation of the tag: I guess it means the event can happen, if you own at least one ocean tile, not that the unit has to be on the ocean.

Furthermore, when I set the iWeight to -1 so that the trigger is active every turn, only one ship will be affected.
Where am I going wrong?

That's a limit (no idea if artificial or not) in the game: Only 1 event per turn.
 
Yeah, I figured out the one event per turn, too.
So, since I'm not an experienced modder at all (just trying to implement the Civ III behaviour for early ships and adding some resources and stuff) - how could this be done?
Some python probably?
 
What exactly?
If multiple events are meant, then there's no way.
Theoretically you could randomly sink ships on ocean tiles, but that's pretty unfair and the AI would not be able to deal with it (means they'd send all their galleys full of troops over a long ocean to invade you, not knowing that probably no ship will arrive).

A real good implementation of what you want would need C++ coding, and probably not even a small amount, due to the AI behaviour.
Doable? Yes. In an easy way? No.
 
Did you compare your event with the EVENTTRIGGER_BERMUDA_TRIANGLE?

I see at least two differences but I don't know if they would make a difference or not:

<iUnitDistanceWeight>-1</iUnitDistanceWeight>
<iNumPlotsRequired>1</iNumPlotsRequired>

The last one might be needed to validate the Ocean terrain.

As for the number of units, you said it yourself that you defined it in <iNumUnits>1</iNumUnits>. It's an integer value required so you can raise it to 2, 3,...

Edit: probably I'm wrong on the last sentence as it might be the number of units on the plot needed to trigger the event. But it's worth trying.
 
Thanks. Worked it out.
The only problem left is that the event triggers far too seldom.
setting iWeight to -1 is too much, I want the boats to have a chance to survive.
Anything but -1 is too low. Even at 500000 it doesn't trigger more than once in 40 turns.

The J said:
Theoretically you could randomly sink ships on ocean tiles.
That's exactly what I want. It shouldn't sink every galley on ocean neither one each turn. But if you look at history, early ships could enter Ocean tiles. The vikings did it. It was highly dangerous, of course, that's why I want the ships to randomly sink. So a probability of about 10 to 15% of sinking each turn would be great.
 
So, for my information, what worked exactly?

More than one ship sink in a turn? (<iNumUnits>?</iNumUnits>)

They sink only in the ocean now? (was it <iNumPlotsRequired>1</iNumPlotsRequired>?)

As for the randomness of the event, a dirty trick might be to create several events 1 2 3 etc with only one sinking the ship (with <bDisbandUnit>1</bDisbandUnit>), put them all in the <Events> tag of your EventTriggerInfos file and re-try with iWeight = -1...
 
Sinking only ships that are on ocean worked.
The problem with the trigger firing not often enough was solved with a little python (I found, to be honest, a very similar event in the CvRandomEventInterface which I adapted to my needs). Basically the event will always be triggered, but the effect will only happen in 33% of cases.

While writing this post I realized that this is not such a great idea. Correct me if I'm wrong but I think this means that as long as there is at least one of Galley, Trireme, War Galley or Siege Quinquireme on ocean, no other event can happen to that Civilization.
Hmpf...
 
Having read a bit more in some tutorials and the modiki and after thinking some more about it, I wonder if this event wouldn't rather fit into "CvEventManager".

The idea is:
Whenever either a Galley, War Galley, etc. is moved into an ocean square (if possible: that is not inside own cultural borders) there is a chance of it sinking. Sinking will be obsolete by the discovery of Tech X (Optics, Astronoy for example) or when the ship has a certain promotion (Seaworthy).
Is this at all possible? It would prevent the random events from being overridden.
 
Rather simple with python.
However, inefficient as you either check it every tile it moves, or check where every unit is end of each turn.
Also, as The_J pointed out, AI won't know about this and it will be unfair to them
 
Well, I'm not too concerned about the AI. Moreover, I planned that affected units travelling over ocean have a chance (say 10%) of being bestowed with a promotion that makes them seaworthy, so the AI (and the player) wouldn't lose all ships.

Alternative:
Another idea is that the ships won't sink in ocean, but either be randomly locked for 1 or 2 turns (because of a calm) or moved to a different tile (since in ancient times navigating on the open ocean was difficult and averse winds and currents make you lose your course).
 
The main issue is efficiency

If you want to do it via python:
Every end of turn, loop through every single unit of every player:
1) To check if the unit is on ocean tile
2) To check if the unit is those crappy naval ships
3) Roll a number and see if it is within the 10% chance
4) Do what you want with it, whether to destroy it, lock it up whatever

In big maps end game, not advisable
 
You have a point there.
Is there no other way to implement this? OK, using the random event seems to work - dunno if it is more efficient, though. And it probably prevents other events from happening, which isn't great as well.

I think I see now why modders/ game designers decided that "cannot enter ocean" was a good idea. Nevertheless I find it unsatisfying.
 
Top Bottom