Hi KJ,
I think there was a misunderstanding.
I never actually implemented that.
I just made a technical concept and checked how difficult it would be to implement that concept.
(Should be relatively easy.)
So I have nothing to upload right now.
(It is also not part of my current plans for RWL.)
I am not sure if I want that feature because I do not feel that it would add fun to the game and I am also afraid that it could really really confuse people.
(The cargo-points would not directly be visible.
You would simply get a Pop-up if you try to load more stuff to your ship and your cargo is full.)
However, after I have finished my currently open stuff, I could implement this for you, before I start something new in RWL, if you want.
(Maybe in about a week or so ?)
Geändert von raystuttgart (17. März 2011 um 21:30 Uhr)
Teammitgleid dieses Projekt für Colonization:
[Mod] We The People
(Nachfolgerprojekt von Religion and Revolution)
Davor Teammitgleid dieses Projekt für Colonization:
[Mod] Religion and Revolution
Vor-Vorheriges Projekt für Colonization:
[ModMod] ray's Wunschliste
Und wiederum davor Teammitglied von:
[Mod] The Authentic Colonization (TAC)
Hi Ray!
I'm sorry. Really, it was a misunderstanding. I thought you already realize your "cargo-points" idea.
No, I don't think this is necessary. I only planned to try your cargo-points idea for harvesting marine resources. If "cargo-points" is not ready, I will seach another possibilities.
I can shortly explain my interest.
I harvest for instance Whale. Cargo size on my boat and at my game speed is 300. I harvest, zB, 10 food/turn. Thus, full cycle of my boat work is equal 300/10=30 turns, or (at speed 1 turn=1 month) more 2 years. Rather long, but acceptable.
Now let's send this boat to harvest a marine resource with output 2 pieces/turn. The same 300/2=150 turns or 150/12= 12.5 years! Absolute nonsense! 1 or 2 years is OK, but not 12.5 years.
Impossible to increase output from the marine tile. 10 food/turn is OK for whale (taking into account whale's size), but for small animals such output is absolutely impossible.
As result now I search the solution.
One of them was "cargo-points" idea. Here the full cycle of my boat work could be shorter 2-3 times because from marine animals I could take not 1 yield with 2 pieces/turn, but 2 or even 3 yields with the same output. Rather far from the optimal one, but a little bit better.
The second solution and probably the optimal one is to create a "special-cargo-slot of smaller size" which "volume" instead 300 would be only 40 or 50. Such "special-cargo-slots" would be available only on some units (boat, whalingboat, hunter, gold prospector). Such small size slot could be used only for yields transpotation. At the moment I will search how to realize this variant.
Why do you make it that complicated ?
Simply code a special logic for that new ship in that method:
bool CvUnit::canLoadYield(const CvPlot* pPlot, YieldTypes eYield, bool bTrade) const
or maybe it is better here
bool CvUnit::canGatherResource(const CvPlot* ePlot, bool bTestVisible) const
Here you make a special logic for your new ship that it cannot load / gather any more goods if it has more than X as sum of the yields in its cargo slots.
-> Very simply, very little chances to get unwanted side effects anywhere else.
Geändert von raystuttgart (18. März 2011 um 10:57 Uhr)
Teammitgleid dieses Projekt für Colonization:
[Mod] We The People
(Nachfolgerprojekt von Religion and Revolution)
Davor Teammitgleid dieses Projekt für Colonization:
[Mod] Religion and Revolution
Vor-Vorheriges Projekt für Colonization:
[ModMod] ray's Wunschliste
Und wiederum davor Teammitglied von:
[Mod] The Authentic Colonization (TAC)
I'm not a programmer and I "can" work with the source codes only if I have a prototype.
Probably, you are right, but I never write any logic by myself.
Anyway I made my first attempt.
I found in the source codes "FullToBrim" and this was my staring point to seach. For me "FullToBrim" means that my boat is full and cannot gather more.
Then I start to search where exactly my boat add some goods.
I found this part in the CvUnit.cpp:
Then I changed this part:Code:bool CvUnit::gatherResource() { // Return true means I am done Fishing or I can't fish anymore if (!canGatherResource(plot())) { return true; } bool bWhalerFull = false; if (!hasMoved()) { if (!isGatheringResource()) { convertFishingBoat(); setGatheringResource(true); } CvPlot* pPlot = plot(); int iCargoSpace = cargoSpace(); BonusTypes eBonus = plot()->getBonusType(); int iNumYieldChanges = GC.getBonusInfo(eBonus).getNumYieldChanges(); std::vector<int> eBonusYieldChanges = GC.getBonusInfo(eBonus).getYieldChangesArray(); if (pPlot != NULL) { for (int i = 0; i < pPlot->getNumUnits(); i++) { CvUnit* pLoopUnit = pPlot->getUnitByIndex(i); if (pLoopUnit != NULL) { if (pLoopUnit->getTransportUnit() == this) { YieldTypes eYield = pLoopUnit->getYield(); if (eYield != NO_YIELD) { int iYieldStored = pLoopUnit->getYieldStored(); int iCargoCapacity = GC.getGameINLINE().getCargoYieldCapacity(); int iLoadedAmount = pLoopUnit->getLoadedYieldAmount(eYield); if ((iYieldStored + eBonusYieldChanges[(int)eYield]) == iCargoCapacity) { pLoopUnit->setYieldStored(iCargoCapacity); eBonusYieldChanges[(int)eYield] = 0; iCargoSpace--; } else if ((iYieldStored + eBonusYieldChanges[(int)eYield]) > iCargoCapacity) { eBonusYieldChanges[(int)eYield] = (iYieldStored + eBonusYieldChanges[(int)eYield]) - iCargoCapacity; iCargoSpace--; pLoopUnit->setYieldStored(iCargoCapacity); } else { pLoopUnit->setYieldStored(eBonusYieldChanges[(int)eYield] + iYieldStored); eBonusYieldChanges[(int)eYield] = 0; } } } } if (iCargoSpace <= 0) { bWhalerFull = true; break; } } } if (!bWhalerFull) { for (int iYield = 0; iYield < NUM_YIELD_TYPES; ++iYield) { if (eBonusYieldChanges[iYield] > 0) { YieldTypes eYield = (YieldTypes)iYield; UnitTypes eUnit = (UnitTypes)GC.getCivilizationInfo(getCivilizationType()).getCivilizationUnits(GC.getYieldInfo(eYield).getUnitClass()); CvUnit* eGatheredUnit = GET_PLAYER(getOwnerINLINE()).initUnit(eUnit, NO_PROFESSION, getX_INLINE(), getY_INLINE(), NO_UNITAI, NO_DIRECTION, eBonusYieldChanges[iYield]); if (eGatheredUnit != NULL) { eGatheredUnit->setTransportUnit(this); } } } } } finishMoves(); if (bWhalerFull) { CvWString szBuffer = gDLL->getText("TXT_KEY_WHALER_FULL", getNameKey()); gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), false, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS3D_UN_OCEAN_END1", MESSAGE_TYPE_INFO, getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_GREEN"), getX_INLINE(), getY_INLINE(), true, true); convertFishingBoat(); setGatheringResource(false); return true; } return false; }
by adding one new lineCode:int iYieldStored = pLoopUnit->getYieldStored(); int iCargoCapacity = GC.getGameINLINE().getCargoYieldCapacity(); int iLoadedAmount = pLoopUnit->getLoadedYieldAmount(eYield);
Code:int iYieldStored = pLoopUnit->getYieldStored(); int iCargoCapacity = GC.getGameINLINE().getCargoYieldCapacity(); iCargoCapacity = iCargoCapacity / 5; //KJ addon: 5 times smaller CargoCapacity for harvesting boats int iLoadedAmount = pLoopUnit->getLoadedYieldAmount(eYield);
Thus, here I made the CargoCapacity of my boat 5 time smaller. Really, the boat with such changes can gather 5 times smaller quantity of resource, then I see a message that my boat is Full to Brim. This change is not affect on other ships.
However, a new problem appears. Manually I can return my ship in home city, unload and send then on bonus tile. But the boat lost automatic possibility to return in home city.
P.S. I never seen such line
What it's mean?Code:iCargoSpace--;
is simply a fast way of saying:Code:iCargoSpace--;
Code:iCargoSpace = iCargoSpace - 1;
Geändert von raystuttgart (18. März 2011 um 23:27 Uhr)
Teammitgleid dieses Projekt für Colonization:
[Mod] We The People
(Nachfolgerprojekt von Religion and Revolution)
Davor Teammitgleid dieses Projekt für Colonization:
[Mod] Religion and Revolution
Vor-Vorheriges Projekt für Colonization:
[ModMod] ray's Wunschliste
Und wiederum davor Teammitglied von:
[Mod] The Authentic Colonization (TAC)
Teammitgleid dieses Projekt für Colonization:
[Mod] We The People
(Nachfolgerprojekt von Religion and Revolution)
Davor Teammitgleid dieses Projekt für Colonization:
[Mod] Religion and Revolution
Vor-Vorheriges Projekt für Colonization:
[ModMod] ray's Wunschliste
Und wiederum davor Teammitglied von:
[Mod] The Authentic Colonization (TAC)
Now I think I understand what you want to do.
I would have a suggestion for you.
Please try the following.
(Out-Comment your own code changes before please.)
See the little red "/ 5" I added ?Code://TAC Whaling, ray bool CvUnit::isFullToBrim() const { if (isFull()) { CvUnitInfo& kUnit = getUnitInfo(); std::vector<int> aiYieldsLoaded; int iNumUnitYield = kUnit.getNumYieldsGatherable(); for (int iYield = 0; iYield < NUM_YIELD_TYPES; ++iYield) { if (kUnit.canGatherYield(iYield)) { aiYieldsLoaded.push_back(iYield); } } CLinkList<IDInfo> listCargo; getGroup()->buildCargoUnitList(listCargo); CLLNode<IDInfo>* pUnitNode = listCargo.head(); int iCargoSpace = cargoSpace() / 5; if (!aiYieldsLoaded.empty()) { while (pUnitNode != NULL) { CvUnit* pLoopUnit = ::getUnit(pUnitNode->m_data); pUnitNode = listCargo.next(pUnitNode); if (pLoopUnit->getYieldStored() != GC.getGameINLINE().getCargoYieldCapacity()) { return false; } iCargoSpace--; if (iCargoSpace == 0) { return true; } } } } return false; }
I think this should do it.
The method isFullToBrim() is used for both aspects:
1) Ship can gather --> CvUnit::canGatherResource(const CvPlot* ePlot, bool bTestVisible) const
2) AI / Automation --> CvUnitAI::AI_workerSeaMove()
Geändert von raystuttgart (18. März 2011 um 23:25 Uhr)
Teammitgleid dieses Projekt für Colonization:
[Mod] We The People
(Nachfolgerprojekt von Religion and Revolution)
Davor Teammitgleid dieses Projekt für Colonization:
[Mod] Religion and Revolution
Vor-Vorheriges Projekt für Colonization:
[ModMod] ray's Wunschliste
Und wiederum davor Teammitglied von:
[Mod] The Authentic Colonization (TAC)
Teammitgleid dieses Projekt für Colonization:
[Mod] We The People
(Nachfolgerprojekt von Religion and Revolution)
Davor Teammitgleid dieses Projekt für Colonization:
[Mod] Religion and Revolution
Vor-Vorheriges Projekt für Colonization:
[ModMod] ray's Wunschliste
Und wiederum davor Teammitglied von:
[Mod] The Authentic Colonization (TAC)
I tested this change:
added:
removed:Code:int iCargoSpace = cargoSpace() / 5;
Result is double negative.Code:iCargoCapacity = iCargoCapacity / 5; //KJ addon: 5 times smaller CargoCapacity for harvesting boats
1. no change of CargoCapacity.
2. my "full to brim" boat cannot return home
OK, tomorrow I will start experiments with TAC 2.02a inoff version. Now I have Whalingboat_0.04.
Sorry, my fault.
Achtung Spoiler:
Please try this:
Line in red.
if (pLoopUnit->getYieldStored() != GC.getGameINLINE().getCargoYieldCapacity())
has changed to
if (pLoopUnit->getYieldStored() < GC.getGameINLINE().getCargoYieldCapacity() / 5)
Important Note:Code:bool CvUnit::isFullToBrim() const { if (isFull()) { CvUnitInfo& kUnit = getUnitInfo(); std::vector<int> aiYieldsLoaded; int iNumUnitYield = kUnit.getNumYieldsGatherable(); for (int iYield = 0; iYield < NUM_YIELD_TYPES; ++iYield) { if (kUnit.canGatherYield(iYield)) { aiYieldsLoaded.push_back(iYield); } } CLinkList<IDInfo> listCargo; getGroup()->buildCargoUnitList(listCargo); CLLNode<IDInfo>* pUnitNode = listCargo.head(); int iCargoSpace = cargoSpace(); if (!aiYieldsLoaded.empty()) { while (pUnitNode != NULL) { CvUnit* pLoopUnit = ::getUnit(pUnitNode->m_data); pUnitNode = listCargo.next(pUnitNode); if (pLoopUnit->getYieldStored() < GC.getGameINLINE().getCargoYieldCapacity()/ 5) { return false; } iCargoSpace--; if (iCargoSpace == 0) { return true; } } } } return false; }
This will only work if you have only 1 Cargo-Slot in the ship you are using for this!
Otherwise isFull() will always be false if you haven't got something in all slots and you will not hit that logic.
Geändert von raystuttgart (19. März 2011 um 01:06 Uhr)
Teammitgleid dieses Projekt für Colonization:
[Mod] We The People
(Nachfolgerprojekt von Religion and Revolution)
Davor Teammitgleid dieses Projekt für Colonization:
[Mod] Religion and Revolution
Vor-Vorheriges Projekt für Colonization:
[ModMod] ray's Wunschliste
Und wiederum davor Teammitglied von:
[Mod] The Authentic Colonization (TAC)
Thank you VERY MUCH, Ray!
You recommended
an this change is working correctly.Code:if (pLoopUnit->getYieldStored() < GC.getGameINLINE().getCargoYieldCapacity() / 5)
- The boat capacity is 5 time smaller, as should be
- The boat automatically returns in his home city, also as should be.
Up to now for 1-slot boats I see no serious errors.
Really, there is some difference in 2-slots boats.
- If 2-slots boat gathers 2 different resources, then 5 times smaller capacity is valid for both slots.
- If 2-slots boat gather only resource of 1 type (YIELD FOOD from bonus FISH tile, for instance), then the first slot has FULL capacity, the second slot has 5 time smaller capacity (that is FULL/5).
- In both cases when the second slot is fulfilled, the boat automatically returns in home city.
I have to make a number additional tests and corrections in this mod because some details are not clear for me yet.
Good to hear.
It is alway a little hard to code just on "paper" without really trying to compile or testing ingame.
(Sorry, I cannot do that right now, because I am too deep in my own changes of DLL-Features.)
I am very sure, that you will not have bugs with the change I have suggested.
No CTDs because of that, I promise.
Pay Attention:
These changes ONLY affect GATHERING.
You will still be able to load the normal amounts of goods in City-Screen or Europe-Screen on the ships.
That is exactly what I expected.
Achtung Spoiler:
However you know the right position of the changes now.
You could relatively easy rewrite that method to do the following:
Speciallogic for certain ships (by UnitTypes !!!) to do what you want and not affecting other units.
Geändert von raystuttgart (19. März 2011 um 10:39 Uhr)
Teammitgleid dieses Projekt für Colonization:
[Mod] We The People
(Nachfolgerprojekt von Religion and Revolution)
Davor Teammitgleid dieses Projekt für Colonization:
[Mod] Religion and Revolution
Vor-Vorheriges Projekt für Colonization:
[ModMod] ray's Wunschliste
Und wiederum davor Teammitglied von:
[Mod] The Authentic Colonization (TAC)