1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Ranged Attack - AI_leaveAttack

Discussion in 'Civ4 - SDK/Python' started by keldath, Jul 8, 2020.

  1. keldath

    keldath LivE LonG AnD PrOsPeR

    Dec 20, 2005
    hi all,

    im working on a variation of ranged attack, base off of VIP mod and DCM and Archer bombard.

    human player code works great.
    ai code works but not perfect.

    my correct issue, is with how to make the ai stop attacking when its odds of survival is no good.
    i thought about using AI_leaveAttack()

    this is my corrent code:

    if (pTargetPlot != NULL)
            if (AI_leaveAttack(1, 30, 100)) // was 20
                return false;
            // K-Mod note: no AI_considerDOW here.
            getGroup()->pushMission(MISSION_RANGE_ATTACK, pTargetPlot->getX(), pTargetPlot->getY(), 0);
            return true;
    i have a setup of one enemy catapult that attacks a city of mine with 3 defenders, equal strength to the catapult. my expected behavior is to check if it should stay and continue or run away to a safe zone/own territory.

    are there any suggestions? maybe another ai function i can harness?

Share This Page