1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  3. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  4. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  5. Dismiss Notice
  6. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

What controls how the AI uses spells?

Discussion in 'Civ4 - Fall from Heaven' started by Mouthwash, Jun 21, 2016.

  1. Mouthwash

    Mouthwash Escaped Lunatic

    Joined:
    Sep 26, 2011
    Messages:
    6,276
    Location:
    Hiding.
    I gave Stephanos an irresistible version of the Domination spell, but he refuses to use it (I confirmed that he has it by using the Stephanos unit in WB). I understand that the caster loses the ability to cast the original version if he is resisted, so maybe there's some reluctance coded in there? I assumed it was the <iAIWeight>, so I changed it to 500 (instead of 50). When that didn't work, I removed that line entirely, since other spells don't seem to have it. Nothing worked. Do I have to go in python or something?

    EDIT: To be clear, I want him to use this ability every single turn it is available.
     
  2. The Crying Man

    The Crying Man Chieftain

    Joined:
    Jun 12, 2016
    Messages:
    11
    i know in coding you could use an if/then statement. so that when certain conditions (such as 2 or more enemies are near him) then he uses the spell. i dont know if that is true for civ 4. Though i do know that AI do have scripting
     
  3. hegemonkhan

    hegemonkhan Chieftain

    Joined:
    Jul 20, 2006
    Messages:
    201
    I don't know any of Civ4's/FFH2mods' various codes at all (only worked with Python a tiny bit), but in general the concepts of coding and coding/logic is this:

    -----------------

    @ The Crying Man

    there's also giving a 'priority/weight rating' indicator/flag too, for an example:

    do I save the hot girl or the ugly girl?

    lower the value, the higher the priority
    higher the value, the lower the priority

    hot_girl.priority = 1
    ugly_girl.priority = 2

    if (hot_girl.priority <= ugly_girl.priority) {
    -> hot_girl.save_her!
    } else {
    -> ugly_girl.save_her!
    }
    // you save the 'hot_girl'

    VS

    hot_girl.priority = 2
    ugly_girl.priority = 1

    if (hot_girl.priority <= ugly_girl.priority) {
    -> hot_girl.save_her!
    } else {
    -> ugly_girl.save_her!
    }
    // you save the 'ugly_girl'

    VS

    hot_girl.priority = 1
    ugly_girl.priority = 1

    if (hot_girl.priority <= ugly_girl.priority) {
    -> hot_girl.save_her!
    } else {
    -> ugly_girl.save_her!
    }
    // you save the 'hot_girl'

    ----------------------------------

    or you could have the opposite too:

    lower the value, lower the priority
    higher the value, higher the priority

    hot_girl.priority = 2
    ugly_girl.priority = 1

    if (hot_girl.priority >= ugly_girl.priority) {
    -> hot_girl.save_her!
    } else {
    -> ugly_girl.save_her!
    }
    // you save the 'hot_girl'

    VS

    hot_girl.priority = 1
    ugly_girl.priority = 2

    if (hot_girl.priority >= ugly_girl.priority) {
    -> hot_girl.save_her!
    } else {
    -> ugly_girl.save_her!
    }
    // you save the 'ugly_girl'

    VS

    hot_girl.priority = 1
    ugly_girl.priority = 1

    if (hot_girl.priority >= ugly_girl.priority) {
    -> hot_girl.save_her!
    } else {
    -> ugly_girl.save_her!
    }
    // you save the 'hot_girl'

    --------------------------------

    @ Mouthwash:

    maybe try changing the <iAIWeight> to 1 or 0 (or maybe even: -1), as maybe lower values have the greater priority, whereas your high value of 500 might have a lesser priority
     

Share This Page