Help needed about cities (SDK, python & SDK+python)

Fabrysse

Charming-snake learner
Joined
Sep 11, 2006
Messages
430
Location
Toulouse - France
I have several things to do with cities, and I have few questions...
Here they are :
  1. probably Python : I want babarian cities to be trapped. So, when a player capture the city, an explosion could kill a lot of the attacker's troops and destroy the city. How to create this explosion (graphics + effects) ?...
  2. Python or SDK : Capture units like GreatPeople, planes... when a city is captured. When a city is captured, all these units are destroyed. I'd like that the winner get these units. How to do that ?
  3. probably SDK : Manage city liberation. When a or several cities on an other continent are liberated (when you create a colony), a leader is choosed. I'd like to choose myself this leader. I suppose it's not so difficult : I want the computer to always choose Mr ThisLeader. How to do that ?

All this is for BTS 3.13 (the later version).
 
Never tried to show an explosion, but luckily it so happens that such an explosion occurs for some of the espionage events. This happens in the SDK. Here's a snip of the relevant code.

Code:
if (pPlot->isVisible(GC.getGame().getActiveTeam(), false))
{
	EffectTypes eEffect = GC.getEntityEventInfo(GC.getMissionInfo(MISSION_BOMBARD).getEntityEvent()).getEffectType();
	gDLL->getEngineIFace()->TriggerEffect(eEffect, pPlot->getPoint(), (float)(GC.getASyncRand().get(360)));
	gDLL->getInterfaceIFace()->playGeneralSound("AS3D_UN_CITY_EXPLOSION", pPlot->getPoint());
}
 
  1. probably Python : I want babarian cities to be trapped. So, when a player capture the city, an explosion could kill a lot of the attacker's troops and destroy the city. How to create this explosion (graphics + effects) ?...

Thanks for your help !
I finally found the way to create trapped cities.
I had an important problem using the event "onAcquiredCity" : if you kill the unit pWinner, the game crashes.
So, I used "onCombatResult", and had to add 2 little things to be sure that a combat will occur when a city is captured :
  • "onCityBuild" : add an immobile unit (it will defend the city if all other units are gone)
  • "onBeginGameTurn" : verify that there is at least 1 defender in all barbarian cities, and if not, add an immobile unit.

For the explosion, I used a function found in Partisans Mod by GIR :
Code:
CyEngine().triggerEffect(gc.getInfoTypeForString("EFFECT_EXPLOSION_CITY"), pCity.plot().getPoint())
I attach here what I wrote.
 

Attachments

  • CvTrappedCityEventManager.zip
    2.4 KB · Views: 101
Top Bottom