Changing a terrain type

DonQuiche

Emperor
Joined
May 23, 2011
Messages
1,122
Hello everyone. I am trying to create an in-game map editor, kinda like the one we had in Civ IV.

I tried to change the terrain type with Plot:SetTerrainType(). Unfortunately, although all data are properly modified (the resources yields and such), the terrain's models and textures are not. The only way to have the graphics updated is to save and reload the game. Would someone happen to know a trick to fix this, please ?

By the way, I currently edit the terrain under the selected unit. Does someone know a better solution, like tile selection ? Looking at the debug files it seems possible but I guess it won't actually work so if someone can confirm or infirm...
 
Hi

Im a complete noob, so probably cant help you, but... is this something like what you are doing?:

plot:SetTerrainType(TerrainTypes.TERRAIN_GRASS,-1);

This works for me when looping over all map tiles, within the ActivePlayerTurnEnd event listener. Maybe if you are not using that particular method, you can check to see if the graphics would get updated properly if you do?

Also, I'm wondering if 'ResetFeatureModel' or UpdateVisibility would be your friends here. Hopefully someone with more brain can tell you if this is the case.

Can I ask, what event / how did you get the currently selected unit?! Thats exactly what im trying to do now, with a 'UnitSelectionChanged' event. But am at a complete loss as to how to get it to give me the unit details.

Dave
 
The game engine can't update terrain graphic change on the fly ATM, the only time the graphics of terrains are updated is during game loading.
 
What Ged said. Features (forest, jungle, etc.), resources*, and improvements can be updated on the fly graphically, but terrain (including hills and mountains) cannot. This is high on a lot of people's wish lists; I've got terraforming in my mod and it suffers from this issue.

*- While adding a resource graphic can be done on the fly, it appears that REMOVING the graphic is more than it can handle for some reason.
 
Thank you very much for your answers. :)

I'm sad to learn about this limitation that ruins my little mod idea. I will still give a shot at what whoshotdk said, with the -1 argument (couldn't figure out anything past the first arg) but my hopes are down.

@whoshotdk
I used the set of hooks used by the UnitPanel (or was it the UnitList ?), here they are :
Code:
Events.UnitSelectionChanged.Add( OnChangeEvent )
Events.SerialEventUnitDestroyed.Add( OnChangeEvent );
Events.SerialEventUnitSetDamage.Add( OnChangeEvent );
Events.UnitStateChangeDetected.Add( OnChangeEvent );
Events.SerialEventUnitCreated.Add( OnChangeEvent );
Events.UnitSelectionChanged.Add( OnChangeEvent );
Events.UnitActionChanged.Add( OnChangeEvent );
Events.UnitFlagUpdated.Add( OnChangeEvent );
Events.UnitGarrison.Add( OnChangeEvent );
Events.UnitEmbark.Add( OnChangeEvent );
Events.SerialEventUnitMoveToHexes.Add( OnChangeEvent );
Events.SerialEventUnitMove.Add( OnChangeEvent );
Events.SerialEventUnitTeleportedToHex.Add( OnChangeEvent );
Events.GameplaySetActivePlayer.Add(OnChangeEvent);
 
Back
Top Bottom