View Full Version : Question about Terrain and Hills
Sureshot Sep 13, 2006, 04:30 PM im a little confused about the implementation of hills.
they seem to be terrain, like theres a 'TERRAIN_HILL' option, but how does that work with grassland/hill or plains/hill?
like if i use the function that gets me the terrain type of the land, what does it say for a plains/hill?
and how do i use the set terrain function to make a hill/plains?
im hoping to edit two spells for my own use, Tsunami and Tremor (or Earthquake, whichever is a 3rd level earth spell), to work in stages, i.e.:
Tsunami
Peak>Hill>Flatlands>Water
Tremor
Water>Flatlands>Hill>Peak
but also make it work 100% of the time, though not work if a city is there (will instead do damage and pop reduce if possible until the city is gone)
but atm, im confused about hills, it seems to me that varying levels of land (water/flatlands/hills/peaks) should be separate from terrain the way features (like forests, fallout, ice) are. the world builder seems to think so as well (it separates those four off from terrain), and adding peaks does not even change the terrain underneath it (if you change a peak back into flatlands it retains the terrain type it had before).
anyone know much about this? how to detect hills? how to change the terrain height? (through python, not worldbuilder)
Chandrasekhar Sep 13, 2006, 05:24 PM Might I suggest making it not work if any unit in the tile succeeds in saving against it? And perhaps a bonus to their saves if they're in a city... just some thoughts I had about it a while ago.
Sureshot Sep 13, 2006, 06:10 PM ya maybe, though people get pushed into other tiles if they survive currently which isnt too bad
but first i need to figure out this hills/terrain business lol
Civkid1991 Sep 13, 2006, 06:25 PM nice idea... i was thinking there sould be an effect like this...
Silverkiss Sep 13, 2006, 06:49 PM Might I suggest making it not work if any unit in the tile succeeds in saving against it? And perhaps a bonus to their saves if they're in a city... just some thoughts I had about it a while ago.
Why the hell should a uber III rank speel cast by an powerfull Archmage be nullified by a lowbie foot soldier saving against it ? He can take no damage if he saves, but the terrain should still be changed.
TheCowSaysMoooo Sep 13, 2006, 07:17 PM From the WorldBuilderSave side of things, hills/peaks/flatland/water are independent from terrain and features. A plot will have TerrainType (grass, plain, desert, etc), FeatureType (jungle, forest, fallout, etc), and PlotType (0=peak, 1=hill, 2=flatland, 3=water), as well as possibly having BonusType, ImprovementType, and maybe another one or two I'm not thinking of off the top of my head.
How this all works with the xml, python, sdk, etc, I don't know, but hopefully it helps get you (or whomever) looking in the right places. =)
Sureshot Sep 13, 2006, 08:41 PM ya, i noticed what you did, but cant find the python equivalent, and it seems to think peaks and hills are normal terrain
Chandrasekhar Sep 13, 2006, 09:02 PM A simple soldier isn't going to be able to save against a spell cast by a level 6+ archmage. The base save could also be difficult to resist, so it's only likely to happen when you're trying to exploit it to wipe out a stack or a city.
Sureshot Sep 13, 2006, 09:19 PM i mean to make it so if a city is involved that nothing will happen to the tile until the city is worn down and off
about stacks, any that make their save doesnt die, they end up on a nearby tile, so ive never found it to be terrible potent on stacks.. on cities tho, its just mean, i cant handle losing a full gigantic city to 1 spell, thats just wrong heh
Uberslacker Sep 13, 2006, 10:18 PM i cant handle losing a full gigantic city to 1 spell, thats just wrong heh
You say that now, but the first time the bastard AI lost a pop 20 city to one of your whims you'd be capering in the streets. :)
Sureshot Sep 14, 2006, 12:00 AM oh ya, and it was funny that i could go around leveling all their cities with 1 unit, but it got old, and feels cheap heh
dreiche2 Sep 14, 2006, 06:21 AM From the WorldBuilderSave side of things, hills/peaks/flatland/water are independent from terrain and features. A plot will have TerrainType (grass, plain, desert, etc), FeatureType (jungle, forest, fallout, etc), and PlotType (0=peak, 1=hill, 2=flatland, 3=water), as well as possibly having BonusType, ImprovementType, and maybe another one or two I'm not thinking of off the top of my head.
How this all works with the xml, python, sdk, etc, I don't know, but hopefully it helps get you (or whomever) looking in the right places. =)
That's the same way it works in Python as far I can see from what I used in my map scripts. There are TerrainType, FeatureType and PlotType, and they can be set independently. Where did you find the string "TERRAIN_HILL", Sureshot?
You can get the types by using:
plot.getTerrainType()
plot.getPlotType()
plot.getFeatureType()
plot.getBonusType(-1)
(the -1 has something to do with teams, I don't know what exactly)
and set them with the appropiate setter functions, which may have specific syntax. Use http://civilization4.net/files/modding/PythonAPI_v160/ as a reference (maybe you knew that one). I think peeking into map scripts is a good way of finding out how all the stuff works.
Sureshot Sep 14, 2006, 10:00 AM sweet thanks :D
and i saw 'TERRAIN_HILL' and 'TERRAIN_PEAK' in the xml files in the terrain infos file
PapaMonkey Sep 14, 2006, 11:17 AM One possible exploit on making terrain modifications (specifically peaks) is that you can cut a city (or an area of land) off entirely by ringing it with peaks. Then only the rangers and a few other units could get in and out. That will be worse for some civs (especially the dwarves with no high level magic to counter this) than others. You may want to limit it so it does not build up to peaks, but stops at hills.
Sureshot Sep 14, 2006, 11:34 AM then id hafta limit tsunami so it doesnt let you place a city inside a small lake (since boats cant be built in small lakes, only in coastal cities on an ocean; so, only water walking units and a few others could get there)
im not too worried about someone blocking themselves in, it can already be done with pirates coves or use of the tsunami spell, and there are always ways around it, either by using the counter spell as im setting it up, or through water walking, rangers, spells like fireball, or a spell extended earthquake/tsunami to encase their center 'protected city' in the same fate as its 'protecting' tiles, thus destroying it.
that is to say, if a city surrounds itself in a small lake, you could use waves to wash away the city eventually, or you could use earthquakes to spread the land across the water to get to them. of if someone surrounds themself with mountains, you can earthquake their city til its destroyed, or use tsunami to erode down its protections.
Sureshot Sep 14, 2006, 11:47 AM i got the following error for code that seems correct:
ArgumentError: Python argument types in
CyPlot.setPlotType(CyPlot, int, bool, bool)
did not match C++ signature:
setPlotType(class CyPlot {lvalue}, enum PlotTypes, bool, bool)
and its because of the line:
pPlot.setPlotType(gc.getInfoTypeForString('PLOT_OC EAN'), True, True)
which basically just replaces:
pPlot.setTerrainType(gc.getInfoTypeForString('TERR AIN_OCEAN'), True, True)
theres a little more too it, but that seems to be the isolated error and i cant figure out whats up
Grey Fox Sep 14, 2006, 12:05 PM I think its supposed to be PLOT_WATER, not PLOT_OCEAN.
Sureshot Sep 14, 2006, 12:17 PM no, its OCEAN, jsut checked again, but also it didnt work for any of the plot types listed, but im pretty sure its not related to that, but im not really sure what it is related to heh
dreiche2 Sep 14, 2006, 01:20 PM Ok, first of all I think things like 'TERRAIN_HILL' found in the XML files define things like terrain boni (which makes sense at least for coast and ocean tiles, with are both the same plot type), though it's somewhat confusing to me..
Now, concerning your error, it seems like for some reason the plottypes are handled differently from the rest (terrain, features, etc.) in that you don't use those info strings. Instead, you use
pPlot.setPlotType(PlotTypes.PLOT_HILLS, True, True)
and you have at your disposal:
PLOT_PEAK
PLOT_HILLS
PLOT_LAND
PLOT_OCEAN
Sureshot Sep 14, 2006, 03:27 PM sweet thanks again :D
knew there must be something wrong with that part but couldnt figure out what
dreiche2 Sep 14, 2006, 04:36 PM yeah it doesn't seem very logical this way. Again, I found it by looking through the map scripts. If you want to change terrain they're a good place to look how it works...
Of course, you can also ask here, so that I get to answer and humanity can profit from my infinite Python/Civ4 Modding wisdom gathered in three days work ;)
Sureshot Sep 14, 2006, 07:17 PM i got the terraforming part of tsunami working perfectly, which makes the terraforming part of earthquake (or tremor) easy, and just need to work out for cities and special cases and im set
Sureshot Sep 20, 2006, 03:47 PM def spellTsunami(caster,target):
doCast(caster)
pPlot = target
if pPlot.isOwned():
startWar(caster.getOwner(), pPlot.getOwner())
for i in range(pPlot.getNumUnits()):
pUnit = pPlot.getUnit(i)
if isResisted(pUnit,caster,0) == False:
iDmg = pUnit.getDamage() + 10 + CyGame().getSorenRandNum(20, "Bob")
if iDmg > 100:
pUnit.kill(True,0)
else:
pUnit.setDamage(iDmg, True)
#if CyGame().getSorenRandNum(100, "Bob") <= gc.getDefineINT('TSUNAMI_FLOOD_CHANCE'):
if pPlot.isCity():
if pPlot.getPlotCity().getPopulation() > 2:
pPlot.getPlotCity().changePopulation(-2)
else:
pPlot.getPlotCity().kill()
else:
pPlot.setImprovementType(-1)
iniPlotType = pPlot.getPlotType()
pPlot.setFeatureType(-1, -1)
if iniPlotType == 0:
pPlot.setPlotType(PlotTypes.PLOT_HILLS, True, True)
if iniPlotType == 1:
pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
if iniPlotType == 2:
pPlot.setBonusType(-1)
pPlot.setPlotType(PlotTypes.PLOT_OCEAN, True, True)
for i in range(pPlot.getNumUnits()):
pUnit = pPlot.getUnit(i)
pPlot2 = findClearPlot(pUnit)
if pPlot2 == -1:
pUnit.kill(True,0)
else:
pUnit.setXY(pPlot2.getX(),pPlot2.getY())
thats the change i did for the tsunami spell, atm it kills a city 2 population at a time, then once its destroyed it it starts terraforming.
personally im gonna do more on it later, but trying to figure out how to know if the city has walls has not been intuitive to me. also i want to do the same for one of the earth 3 spells but in reverse, but tremor and earthquake both seem to be AoE spells, not targetted.
DieselBiscuit Nov 09, 2006, 08:01 AM personally im gonna do more on it later, but trying to figure out how to know if the city has walls has not been intuitive to me.
This should do the trick:
pPlot.getPlotCity().hasBuilding(gc.getInfoTypeForS tring('BUILDING_WALLS'))
steel.stiletto Nov 09, 2006, 02:50 PM I'm not sure, but I think that there are more than just those types of walls. I'd have to look into the code myself, but I think that the walls that a mage adds (via "walls of stone" or some such similiar spell) would also need to be asked for then. It makes the code nastier (having to explicitly ask for each type), but I think that it probably would need to be done.
Sureshot Nov 09, 2006, 03:24 PM i think walls of stone would be needed for it as well to achieve the effect im looking for. though i have the tremor spell changed into a targeting spell counter to tsunami, quite a fun time shaping the land with them.
|
|