Lua Event - an enemy attacks your unit

Discussion in 'Civ5 - Creation & Customization' started by martijnaikema, Jan 11, 2011.

  1. martijnaikema

    martijnaikema Warlord

    Joined:
    Oct 30, 2010
    Messages:
    111
    Hi,

    I am looking for a LUA event that can be triggered before an enemy decides to attack my unit. If my unit is on a river tile I need to change his strength and give him a defense bonus.

    With some help here on the forum I figured out how to give the attack bonus. I used the LUA event SerialEventMouseOverHex. When there is a unit on that plot and I am at war with them, then I can adjust the strength.

    So it will be like:
    * Trigger: Enemy Unit wants to attack
    * Check if my unit is on a river
    * If so change combat strength

    But I also want to give my unit a defense bonus when it is attacked and my unit is on a river tile. I just don't know which LUA even I will have to use. I tried different onces but haven't found the right one yet.

    Thanx in advance!

    Greetings,
    Martijn

    edit: just after posting I realised how I could do it:
    * after turn end loop over all units
    * check if unit is the type that receives bonus
    * check if unit is on à river plot
    * give bonus

    Then reset at turn start.

    But would that work if the computer plays the civ that would get the bonus?
     

Share This Page