Modders Guide to FfH2

Seems like that might work fairly well, since the function carries a pointer to the old plot directly and I don't recall it asking for plot() personally anywhere. But it could cause issues with some of the other checks which are performed before the unit is properly moved to a new plot.



I had tried moving the 2 plot visibility changes (both old & new) up to the front of the function, wound up with a lovely crash from that. So instead I just nested the invisibility check in visibility updates for the new plot (I activate the unit's visibility on the new plot, do the invis check, then deactivate the visibility once again, leaving it inactive until the normal location for updating it)

I have been thinking about this function some more. If I have my logic right:

newUnit moves into, or is created in, a plot containing zero or more existingUnit.
If there are any existingUnit, newUnit will do one of four things.
1. Co-exist with existingUnit,
2. Push existingUnit out of the plot,
3. Be unable to enter the plot and be forced back to where it came from,
4. Be unable to enter the plot and be forced to a random nearby plot.

I think, at the moment, as each existingUnit is checked in loop, where there is more than one it is possible that some will be forced out when in fact newUnit is then denied access by a later existingUnit further through the loop? Should it in fact loop through each existingUnit to see if it will be permitted access to the plot, then if so loop through again to see if any of the existingUnit can coexist?

The reason for 3 and 4 above, is that in some cases setXY will be used for a normal movement type action, in other cases it may be used for teleportation or spawning of units. Should the decision for what to do in event of failure be down to the calling function rather than setXY?
In the case of units being created with initUnit, they won't have a prior plot, so we need to decide whether to spawn anyway in a different plot, or abandon the spawn. Is this addressed anywhere already, am I just missing it?

Just thinking, is it worth checking for Fear on newUnit or existingUnit?
What about Held? Should a unit be Held so solidly that it would prevent teleport/spawn/movement into the plot?
 
Where are you seeing 3 & 4? If setXY is run, the unit WILL be placed in that plot. All other units in the plot might get moved or killed, and if the unit moving has cargo more units may be brought into the tile, but without fail, that unit who is running setXY WILL wind up in the new plot, for precisely the reason you stated, whatever is calling the setXY function has to decide before that point if it is allowed or not.
 
Where are you seeing 3 & 4? If setXY is run, the unit WILL be placed in that plot. All other units in the plot might get moved or killed, and if the unit moving has cargo more units may be brought into the tile, but without fail, that unit who is running setXY WILL wind up in the new plot, for precisely the reason you stated, whatever is calling the setXY function has to decide before that point if it is allowed or not.

OK, that's good then, easier than I thought. (I'm sorry, I have a cold!)

EDIT:
oh yeah, remembered, I was thinking of noncombat units and capturables. I thought perhaps setXY might be used in movement, sorry I'm new to the sdk :)
also I was thinking that if existingUnit is not moveable(the immobile Held units I was considering) then we don't want quandaries.

So possibilities are : existingUnit kicked out, stays, or is captured. newUnit always enters plot. (possibly, newUnit ought to be captured on the spot if capturable to avoid need to step out-and-in again?)
 
Would it be possible (preferably in python without SDK changes) to extend the minimum number to turns that must pass before canceling diplomatic agreements (peace treaties, cease fires, resource trading, open borders, etc.)?

I just got to thinking that a spell that causes diplomatic agreements to be more binding would fit perfectly in the Force sphere.
 
There's no easy way. If it's possible you have to remake the deals using CyDiplomacy. It is not in the SDK nor have I ever used it so can't help you there. CvDiplomacy.py (from BtS, not used in FfH2) might provide some help.

...unless you want to extend ALL deals (for everyone). Then you can use GC.setDefineINT("PEACE_TREATY_LENGTH", newlength)
 
Is that something that can be changed in game with a python spell? I think that changing the duration of all deals would be fine for Force spells, at least if we have 2 versions, one to extend deals and one to shorten them.
 
I made a change on 'p' and I don't get the crash:
Code:
(cvUnit.cpp line 10470 ->)

	pNewPlot = GC.getMapINLINE().plotINLINE(iX, iY);

	// MARNOK
	if (plot() == NULL)
	{
            m_iX = iX;
            m_iY = iY;
	}
	// MARNOK END

	if (pNewPlot != NULL)
	{
	    // MARNOK
	    // on xienwolf's suggestion
	    pNewPlot->changeAdjacentSight(getTeam(), visibilityRange(), true, this, true); // needs to be here so that the square is considered visible when we move into it...
		// MARNOK END

		pTransportUnit = getTransportUnit();

I suspect I put the changeAdjacentSight in the wrong spot though, because what happens is, when I do my initUnit then convert, some adjacent plots become non-visible (even though I have units in them).
 
Different question.
Can anyone think of the best way to stop Acheron being buildable, in python?
Supposing someone wanted to
Spoiler :
create a persistant lair result with a sleeping dragon, who might awaken at any moment, and wanted to make sure the Barbs did not build Acheron in a city before it was created in the lair
, what would be the best way?
I was thinking perhaps using some kind of variable and putting an extra line in canTrain under Acheron's entry, but is there some way which is cleverer?
 
You mean to do it without any XML modification for the Scenario Design contest? Will be a bit harder if so. But I suppose one easy way to do it would be to choose a feat which the Barbarians don't use (worldspell is ideal) and set that feat for the Barbarians when the Lair Result is granted to someone, then have Acheron require the feat.
 
I would probably just use the GAMEOPTION_NO_ACHERON option that is already used in most of the scenarios.
 
You mean to do it without any XML modification for the Scenario Design contest? Will be a bit harder if so. But I suppose one easy way to do it would be to choose a feat which the Barbarians don't use (worldspell is ideal) and set that feat for the Barbarians when the Lair Result is granted to someone, then have Acheron require the feat.

Thanks, sounds good. It's not for the SDC, just for general modding.
 
Can someone tell me how to make a special terrain appear in a specific civ?(Like the Hellfire and Burning Sands terrian in the Infernal civ)
 
I have been trying to make my own image pak file, and it creates fine. I can open it and see the files with dragon unpacker, but none of the images load, including the ones that already existed before I added my new ones.

The directories look fine. Is there anything special I need to do to create my own image pake file? Is there a compression setting I need, or anything?

I'm using pakbuild. I unpack the image file into a clean directory. Add my images. Pak it all back up. And then, no images work.

Thanks.
 
I'm trying to add a new civ to FFH,but every time the game loads it crashes.Can someone help me?
 
Hello! Could someone tell me where in the SDK the AI evaluates the terrain to identify ideal city locations? What sort of changes, if any, does FFH2 have that might influence it? I'm in the formative stages of learning the SDK and C++ and am trying to narrow down which parts need tweaking for the Malakim mini mod I'm contemplating.

Perhaps the AI in general could use some help in this department in order to better tailor its choices for all the different FFH2 leaders? Seems the AI doesn't do terribly well with some of its early city choices, or more precisely choosing locations that marry up well with their chosen techs and vice versa.

Anyway, I'm getting ahead of myself, mainly I'm just trying to figure out how the game looks at the map and chooses tiles to settle on.

edit:
Additionally, I need to figure out how cities count features in their BFC (as in forest health, etc) and if it could be extended to terrain (desert). Where in the SDK is this happening?

edit2:
Also, so as not to reinvent the wheel, if anyone knows of any mods that already focus on similar mechanics, it might help a lot. I found a mod that implements a doctor specialist and it helped a lot in getting my head around the tweaks needed to add a new specialist. Turns out that is probably going to be the easiest part of my idea. Linking it to the city terrain and letting the AI benefit from it will be the harder part.

more info about the idea I'm tackling in this thread:
http://forums.civfanatics.com/showthread.php?t=305986
 
One thing which will help you is to see the values that the AI already places on each tile for founding a city there. If you use Chipotle, that is easily identified. Here is my listing of what chipotle can show you (note, there are things in here which I added to Fall Further, but I should have remembered to mark all of those clearly.


_____________________________________________________

CTRL+MOUSE_HOVER
  • Hover a unit in city zoom (to select for building)
    • Displays the numerical value that the AI assigns the unit for each possible UnitAI (so if the highest number doesn't match what you want the AI to do with the unit, something needs tweaked. ie - Stonewarden's highest value by a longshot is City Attack.... oops!)
  • Hover a Building in City zoom (to select for building)
    • Displays the numerical value that the AI assigns to the building
  • Hover a City
    • Shows Danger Value for the owner's AI consideration, Defenders and Workers that it has and needs as well as closeness calculations for the player/team
  • Hover a unit
    • ID & Current Mission (including destination), also Group ID and average health
  • Hover any Owned Tile
    • Civic values for that Civilization
  • Added: Hover a name on the Scoreboard
    • Contribution to the AC from that Player and top 2 Techs (with Weight Values, excluding an up to 2000 point random weight used when decisions are made)
  • ADDED - Any Tech
    • Same as ALT hover, but list is reversed (for games with lots of players and list overflows screen)

ALT+MOUSE_HOVER
  • Hover owned Territory
    • Shows the AI that the player is using, how many cities they control
  • Hover a City
    • Shows rankings for the Civilization who owns it for each Yield & Commerce type
  • Hover any tile
    • Values for city founding in that plot for all relevant players plus info on the number of sites an AI has selected in the area. If the plot is one of the selected ones for an AI then a yellow X appears next to the player. Also shows how many missionaries the plot owner thinks he needs (if more than 0) and shows PlotDanger if there is any EnemyOffense value detected and a relative power scale. Shows AI Strategy type and battleplan
  • Hover a Unit
    • Indicates Group Number, size and if they are leading the group
  • Hover a Tech
    • Shows a list of all Players who are alive which tells: LeaderName: CurrentResearchItem (ResearchPerTurn->NumTurnsToCompleteCurrent)(CurrentStoredResearch/TotalNeededResearch)<<ADDED>>(TopTech=Score)(SecondTech=Score)

SHIFT + MOUSE_HOVER
  • Hover a Unit
    • Assigned AI Type & Sacrifice Value (Sacrifice Value is used when trying to break a city/stack. If odds are not favorable, highest Sacrifice Value is sent in to die first)
    • <<ADDED>> ArtStyle by unit & Civilization, and Art Define Tags
  • Hover any Tile
    • X/Y Co-ordinates, Area ID, River Flow Direction (if any), Found values (generic player), plotgroup assignment and bonuses available for that group (seems to only show bonuses the active player can see, with bonus values according to active player's AI), Culture Values (precise numbers), tells what the bestbuild is for the plot (improvement workers want to place there) & Stack Strength Breakdown. If tile is a city, it will display "I spy with my little eye..." "also UnitCombat Types...." which is supposed to show the UnitClassWeight and UnitCombatWeight values for the city owner. Since nothing shows at all anytime I try it, I am quite confused as to what the weights are.
    • Added: Plot Counter, Number of Evil Tiles in this defined Area

SHIFT + ALT + MOUSE_HOVER
  • Hover a tile in City Radius
    • Tells if City is working it and how highly the city values working on it, if a bonus present, tells all player's value toward that bonus
  • Hover a City
    • Shows a map of all workable tiles, highlighting those worked and stating value of working for each tile, also has multipliers for yields via player/city/specialist, plus commerce exchange rates, and shows if Finaincial Trouble ($$$!!!)
  • Hover a Resource
    • Shows value each AI places on that resource


CTRL + ALT + Z - Change Human control to next Player (Doesn't seem to work for looping back to Player 0 where you started though)

CTRL + ALT + D - Opens Debug Menu, lots of things you can do in here, the only ones I understand are ones well explained or that I have played with. Careful, some of these can crash the game when you select them. Some amazing tools though for figuring out graphics, especially the LSystem and Tree crap.

SHIFT + [ - Decreases a units strength that your mouse is over by 0.2.
SHIFT + ] - Increases a units strength that your mouse is over by 0.2.
SHIFT + T - Add a tech or Gold to any player
CTRL + ALT + 4 - Increases your gold by 1000.
SHIFT + CTRL + LEFT_CLICK - Place Objects menu. Quickest way to make a stack of units for testing purposes. Can add any number of units or a city to any player








Other Commands:

CTRL + SHIFT + A - Toggle Autosave on/off

<<ADDED>>CTRL + SHIFT + Z - Disable AI AutoPlay or Pop-up to enable for specified number of turns

<<ADDED>>CTRL + SHIFT + X - enable AI AutoPlay for 1 turn

_______________________________________________



As for precisely where the AI makes decisions on where to place a city is in CvPlayerAI::AI_foundValue(int iX, int iY, int iMinRivalRange, bool bStartingLoc)
 
Whoah! Fun tool! Many thanks Xienwolf. :clap:

Is the CTRL + SHIFT + X for a 1 turn autoplay only enabled for FF? Doesn't seem to work for me in FFHq, though I was able to use CyGame().setAIAutoPlay(1) easily enough.

Quick question on this line of code:
Code:
pPlot = GC.getMapINLINE().plotINLINE(iX, iY);
Is GC referring to "Garbage Collection"? Thats all I could find in my searches that made any sense. Any clarification on what that is would be helpful. Also, the INLINE is basically telling the compiler to copy the whole function there to speed up processing speed?

I'm slowly figuring out the AI_foundValue function.

After running some Kuriotates autoplays, it seems like they might benefit from a more complicated version though I'm still a ways from figuring out what provisions have been made for them thus far. Just feels like they should try to spread their super cities out a little more and avoid empty ocean squares far more than they are.
 
Oops, C_S+X and C_S+Z are just for Fall Further, marked those now.

GC means GameCore, it is a section of the DLL program. INLINE is a method of grabbing data slightly quicker than the non-INLINE method, not sure if there is a tradeoff, or if it is just plain faster and better all around. You can't just tack it onto any old function though it has to exist as an INLINE already :)

Kuriotates AI in base FfH are forced to settle everything as a real city until they reach their limit. IIRC testing from other players showed that they do fairly decent with upgrading settlements into cities whenever a space is opened up for them to do so.

In Fall Further, I modified it so that Kuriotates AI are forced to settle everything as a city if it is more than 6 tiles from their nearest other city, otherwise they are forced to settle as settlements (till their city cap of course). There is no restriction in place yet to prevent them from making the settlement instantly into a city, so I do not know if it helps them at all just yet.
 
Back
Top Bottom