Zlatko
CIW
One more quick python thing. I'm trying to make a land mine that's invisible, and have it so that whenever a unit moves into the same space as the land mine, the land mine gets killed and the unit gets damaged.
I put this in onUnitMove in CvEventManager:
But it's not doing anything at all...when I move units into the land mine square they just sit there.Code:#Land mine for i in range(pPlot.getNumUnits()): pOtherUnit = pPlot.getUnit(i) if pOtherUnit.getUnitType() == gc.getInfoTypeForString('UNIT_LAND_MINE'): pOtherUnit.Kill(0,PyPlayer(pOtherUnit.getOwner())) iRnd = CyGame().getSorenRandNum(100,"Land Mine") pUnit.changeDamage(iRnd,pUnit.getOwner())
I'm thoroughly stumped...what should I do?
Just set damage to both units to 100 and you are done. Some example from my mod.
You can found a lots of python examples in my mod and PLAY them, it's very interesting. RECONSTRUCTION THREAD.
And i suggest you to download platyping megapack and gigapack you really can found a lots of examples there and this can help you too CIV 4 PYTHON API
Code:
if pLoser.isHasPromotion(gc.getInfoTypeForString("PROMOTION_HARMONY_POISON")):
if pWinner.getDamage() >= 80:
pWinner.setDamage(100, false)
CyInterface().addMessage(iPlayerWinner,true,10,CyTranslator().getText("TXT_HARMONY_POISON",(pWinner.getName(),)),'',0,'',-1, -1, -1, true,true)
CyInterface().addMessage(iPlayerLoser,true,10,CyTranslator().getText("TXT_HARMONY_POISON",(pWinner.getName(),)),'',0,'',-1, -1, -1, true,true)
pPlayerLoser.changeCombatExperience(1)