[PYTHON] Landmine Triggers

Miuna

Chieftain
Joined
Jul 29, 2020
Messages
13
Would it be possible to create a trap/landmine which detonates upon being stepped upon? I did some research around but can't find anything for civ4 (though it did seem someone did something like this for civ5 but i don't really play that so i can't see if there is anything harvestable.

I was hoping it could be something which once stepped on would deal either x damage or y% damage.

Is this doable or does anyone know of any other mod which uses something similar to this?
I'm equally contemplating if this should be a improvement (such as built by workers) or if to keep this as a unit type (which could then be capped as a limited unit).
 
If you don’t want it to be obvious where it is, then it’s better to do it as an invisible unit. That would also allow for the owner’s units to move through a minefield, whereas enemies set them off. If you want minefields to be obvious obstacles, then an improvement approach could work but you have to avoid the tile yourself then.
As units, they should obviously be immobile. You could handle the triggering of the mine through python.
If they are invisible units, then I don’t think just giving them a high defence would work but python triggered when a unit moves onto a mine or during the owners turn if an enemy has stopped in a mine could work.
An improvement would have the benefit of using the python hooks when someone enters the tile, rather than onUnitMove. If you want that benefit and still want to be able to traverse your own minefields, then you could have a minefield unit spawned by python when a minefield improvement is built.
If you use a visible minefield unit, then you could avoid recurring python completely by just giving it a very high defence (and a vulnerability to sappers) to reflect the damage it causes when an enemy unit moves into it. However, in that case you’ll still want to code some python to handle placement of the minefield and limiting the number of minefields per tile.
 
Thank you for the reply.
I was leaning towards the idea of a unit, I like the concept of it not being visible whilst maintaining safety to the owner.

I was wondering however, is it possible to use the OnMove command in python to trigger the mine upon units moving to the tile, but instead the mine having a defence stat it would act as a defenceless unit (like great people for example, no combat strengths) which just detonates causing either a fixed damage value (%) or equal to collateral damage (similar i suppose to how bomber planes do but this would be triggered via the move command over using a actual skill/unit ability).
Is this being needlessly complicated?
 
Top Bottom