Mine fields

PPQ_Purple

Purple Cube (retired)
Joined
Oct 11, 2008
Messages
5,762
I have been looking for this and have not found it so far. The concept is that there is an inprovement that does a certain precent damage per turn to all unts that pass through it. Kind of like snow storms in FFH1. But it only affects units that belong to players who are at war with the player that owns the plot upon witch it is located.
Has it been done before? Can it be done at all?
 
It could be done using python. In CveventManager there is a function called onUnitMove.
 
Ok, explain please. If possible write the code.
 
This example should work. You would have to create a new improvement for the mine field. For this example I just used the standard mine improvement (as in coal mine) from the game.

Code:
 def onUnitMove(self, argsList):
  'unit move'
  pPlot,pUnit,pOldPlot = argsList
  player = PyPlayer(pUnit.getOwner())
  unitInfo = PyInfo.UnitInfo(pUnit.getUnitType())
  if pPlot.getImprovementType() == gc.getInfoTypeForString("IMPROVEMENT_MINE"):
   if gc.getPlayer(pPlot.getOwner()) != None:
    if player.getTeam().isAtWar(gc.getPlayer(pPlot.getOwner()).getTeam()):
     pUnit.setDamage(pUnit.getDamage() + 10, -1)

This code damages the unit by 10 percent. You can change the pUnit.getDamage() + 10 to something different if you want more, less or possibly a random value.
 
You can also use the onUnitmove to a unit that is invisible to everyone except the player that built it. I used this concept in my Dungeon Adventure modmod of FfH2 to create traps.

The problem with improvements and most other WB things is that they show up on screen in the mouse-over information.

Using an improvement is easier -- but if you want the thing to be hidden from view until someone stumbles into it, you will need to create an new immobile unit.
 
Using an improvement is easier -- but if you want the thing to be hidden from view until someone stumbles into it, you will need to create an new immobile unit.
Thats a good point, I didn't think about the invisible part. It could be done with improvements by modifying the help strings in CvMainInterface to remove any mention of mines and using modified graphic files. That would of course add some extra work.
 
I thought of having it as an improvement that has no model, and hence it would not show up on the screen.
The problem with having it as an unit is that it could be destroyed by other units once it is revealed. Something that is quite unrealistic.
 
I thought of having it as an improvement that has no model, and hence it would not show up on the screen.
The problem with having it as an unit is that it could be destroyed by other units once it is revealed. Something that is quite unrealistic.

easily fixed or avoided with python coding. If the unit is invisible, it will not interact with other units. And even if it somehow does, you can code so that the unit will automatically regenerate (onUnitKilled, calling for an initUnit of the same unit type on the same plot).

I think my DA modmod files are still hosted. Feel free to download them (they are in the FfH2 subforums) unpack them and see how the coding works. The traps I had worked very well!
 
SO FFH2 has traps in it? In that case I guess they could easily be reworked into mines.
But the idea was to have a miner unit, that would be a proto worker (can only lay and remove mines).
I could make it that the miner sumons the unit, but than we could encounter mine spams. (10 mines = 100% damage)
 
Vanilla FfH2 does not have traps. The Dungeon Adventure mod mod I worked on does. You can find that thread here:

http://forums.civfanatics.com/showthread.php?t=267995

The modmod was abandoned and never finished, but a lot of the ideas did get incorporated into vanilla FfH2. Traps didn't make it in, though. Nevertheless, the thread has some good discussion about traps and many other topics.

That modmod thread really ended up being a good discussion forum to try out new coding ideas. Also, FWIW, the FfH2 forums are one of the best places to get ideas for coding -- some very creative people hang out there.

Check it out!
 
Thanks, I shall.
Could you check out my other question too please?
You seem to know what you are doing.
 
Top Bottom