Author Topic: Jasperre's AI - anyone?  (Read 424 times)

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Jasperre's AI - anyone?
« on: August 29, 2012, 05:50:00 pm »


               Does anyone use Jasperre's AI? I'm currently looking at it to make a few battles a little more challenging but I'm a little confused about how it works.

I imported the non-override version of the scripts and nothing more.

I then placed the relevant scripts on the NPC's script slots.

j_ai_onblocked
j_ai_oncombatrou
j_ai_onconversat
j_ai_ondamaged
j_ai_ondeath
j_ai_ondistrubed
j_ai_onheartbeat
j_ai_onpercieve
j_ai_onphiattack
j_ai_ononrest
j_ai_onspawn
j_ai_onspellcast
j_ai_onuserdef


I created a level 5 Priest with the following spells:

Level 0
[None]

Level 1
1x Bane
2x Cure Light Wounds
1x Doom
1x Entropic Shield

Level 2
1x Aid
1x Darkness
1x Hold Person
1x Silence

Level 3
1x Blindness/Deafness
1x Dispel Magic
1x Invisibility Purge
1x Protection from Elements

She has no special abilities.

With all of this said, in combat, the Priest goes about casting Inflict Serious Wounds and Inflict Medium Wounds.

I even went and removed all references to any Inflict ??? Wounds from all spell levels she knew, yet in battle, she's running about casting Inflict Serious Wounds and Inflict Medium Wounds, which ruins my test character and general balance and challenge I am trying to create using this script set.

In testing, she casts Inflict Medium Wounds 21 times as I stood there in dm_god mode.

Now, she does use spells in which I've given her, I just can't locate any spawn settings in j_ai_onspawn that forces an NPC priest to cast such a spell like Inflict Serious or Medium Wounds like she's the touch of death itself.

I'm reaching out! Hope there's a few who use the package and can help me understand this.

Thanks,

FP!
               
               

               


                     Modifié par Fester Pot, 29 août 2012 - 04:55 .
                     
                  


            

Legacy_BelowTheBelt

  • Hero Member
  • *****
  • Posts: 699
  • Karma: +0/-0
Jasperre's AI - anyone?
« Reply #1 on: August 29, 2012, 06:30:06 pm »


               Sounds like your caster (or at least the default scripts) may be set up to cheat-cast those spells.

Do a search for either the constant AI_CHEAT_CAST_SPELL or the function SetAICheatCastSpells and see if the calling scripts are set up with those spells.

Not sure if that's the trouble, but it is a place to start.
               
               

               


                     Modifié par BelowTheBelt, 29 août 2012 - 05:31 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Jasperre's AI - anyone?
« Reply #2 on: August 29, 2012, 06:49:43 pm »


               Isn't it just the clerics get to cast cures or inflict automatically if they have any spells of that particular level?  So try a mage instead and see what happens.  Not really a solution but maybe it will help to identify the problem.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Jasperre's AI - anyone?
« Reply #3 on: August 29, 2012, 07:01:18 pm »


               GetHasSpell returns 1 for each spontaneous use of inflict/cure spell which is the problem there - yet i dont recall this being problem with Jasperre's AI before (I was using this few year ago), maybe the behavior changed thorough latest patches (which is possible as this is not written in lexicon) and thus afflict AI in such regard

I found this being problem also in my own attempt to make default AI a bit clever (published in community patch) the clerics are casting the inflict spells on PC when they didnt do that before and its also not really smart tactics.

Anyway - what I can suggest is to write your own AI for each unique creature you need - assuming you do need this only for bosses. The default AI at least with the improvements I did in community patch isnt that bad for common monsters. (if you dont know how to make special AI script for monsters I can explain + add my script for one of my epic spellcaster)
               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Jasperre's AI - anyone?
« Reply #4 on: August 29, 2012, 11:01:34 pm »


               

BelowTheBelt wrote...

Sounds like your caster (or at least the default scripts) may be set up to cheat-cast those spells.

Do a search for either the constant AI_CHEAT_CAST_SPELL or the function SetAICheatCastSpells and see if the calling scripts are set up with those spells.

Not sure if that's the trouble, but it is a place to start.


I've done a search for AI_CHEST_CAST_SPELL, as well as SetAICheatCastSpells and only the latter appears in the j_ai_onspawn.

//SetAICheatCastSpells(SPELL_MAGIC_MISSILE, SPELL_ICE_DAGGER, SPELL_HORIZIKAULS_BOOM, SPELL_MELFS_ACID_ARROW, SPELL_NEGATIVE_ENERGY_RAY, SPELL_FLAME_ARROW);
        // Special: Mages cast for ever with this set.


It's commented out.

Additionally, mages work as expected. It's just the clerics that are annoyingly casting a spell they do not have.

AI_CHEAT_CAST_SPELL is referenced in j_inc_spawnin, which is an include of j_ai_onspawn, but there is no mention of the spell being cast.

void SetAICheatCastSpells(int iSpell1, int iSpell2, int iSpell3, int iSpell4, int iSpell5, int iSpell6)
{
    SetAIConstant(AI_CHEAT_CAST_SPELL + IntToString(i1), iSpell1);
    SetAIConstant(AI_CHEAT_CAST_SPELL + IntToString(i2), iSpell2);
    SetAIConstant(AI_CHEAT_CAST_SPELL + IntToString(i3), iSpell3);
    SetAIConstant(AI_CHEAT_CAST_SPELL + IntToString(i4), iSpell4);
    SetAIConstant(AI_CHEAT_CAST_SPELL + IntToString(i5), iSpell5);
    SetAIConstant(AI_CHEAT_CAST_SPELL + IntToString(i6), iSpell6);
}


It is not in the NPCs j_ai_onspawn, nor are there any references of cast cheating.

There are the only flags available in the j_ai_onspawn for Clerics.

/************************ [Combat Other - Healers/Healing] *********************
    Healing behaviour - not specifically clerics. See readme.
************************* [Combat Other - Healers/Healing] ********************/
    //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_HEAL_AT_PERCENT_NOT_AMOUNT, AI_OTHER_COMBAT_MASTER);
        // if this is set, we ignore the amount we need to be damaged, as long
        // as we are under AI_HEALING_US_PERCENT.
    SetAIInteger(AI_HEALING_US_PERCENT, 30);
        // % of HP we need to be at until we heal us at all. Default: 50
    SetAIInteger(AI_HEALING_ALLIES_PERCENT, 40);
        // % of HP allies would need to be at to heal them Readme = info. Default: 60
    //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_WILL_RAISE_ALLIES_IN_BATTLE, AI_OTHER_COMBAT_MASTER);
        // Turns on rasing dead with Resurrection/Raise dead.
    //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO_CURING, AI_OTHER_COMBAT_MASTER);
        // This turns off all healing.
    //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_ONLY_CURE_SELF, AI_OTHER_COMBAT_MASTER);
        // This turns off ally healing.
    //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_ONLY_RESTORE_SELF, AI_OTHER_COMBAT_MASTER);
        // This turns off ally restoring (Remove/Restoration).
    //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_USE_BAD_HEALING_SPELLS, AI_OTHER_COMBAT_MASTER);
        // This forces all cure spells to be used, check readme.
    //SetAIInteger(SECONDS_BETWEEN_STATUS_CHECKS, 30);
        // Seconds between when we loop everyone for bad effects like Fear/stun ETC. If not set, done each round.
    //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_GIVE_POTIONS_TO_HELP, AI_OTHER_COMBAT_MASTER);
        // ActionGiveItem standard healing potion's to allies who need them, if they possess them.

/************************ [Combat Other - Healers/Healing] ********************/


ffbj wrote...

Isn't it just the clerics get to cast cures
or inflict automatically if they have any spells of that particular
level?  So try a mage instead and see what happens.  Not really a
solution but maybe it will help to identify the problem.


The mage along side of the Cleric, works as expected. It's a Mage and Cleric encounter, and the Cleric is the one causing the problem.

ShaDoOoW wrote...
Anyway - what I
can suggest is to write your own AI for each unique creature you need -
assuming you do need this only for bosses.


I don't have the knowledge of scripting to create my own AI scripts, so I have to work with what's available by
others.

EDIT: I've been searching the net for information regarding this annoyance and came across a bug list of fixes a Nordock server made. One of them:

fix to jasperre ai to prevent unlimited casting of inflict (& cure) moderate wounds

It's all I could find, minus the fixes they made.

Looks like this package is bugged?

FP!
               
               

               


                     Modifié par Fester Pot, 29 août 2012 - 10:58 .
                     
                  


            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Jasperre's AI - anyone?
« Reply #5 on: August 30, 2012, 12:06:27 am »


               EDIT2:

After searching all the scripts for INFLICT_, I ended up commenting out the following lines in j_inc_generic_ai:

// Inflict Serious Wounds. Level 3 (Cleric) Touch attack, hit means 3d8 + 1-15 negative //if(AI_ActionCastSpontaeousSpell(SPELL_INFLICT_SERIOUS_WOUNDS, SpellOtherSpell, GlobalSpellTarget)) return TRUE;

// Inflict Moderate Wounds. Level 2 (Cleric) Touch attack, hit means 2d8 + 1-10 negative damage
//if(AI_ActionCastSpontaeousSpell(SPELL_INFLICT_MODERATE_WOUNDS, SpellOtherSpell, GlobalSpellTarget)) return TRUE;

// Inflict Light Wounds. Level 1 (Cleric) Touch attack, hit means 1d8 + 1-5 negative damage.
//if(AI_ActionCastSpontaeousSpell(SPELL_INFLICT_LIGHT_WOUNDS, SpellOtherSpell, GlobalSpellTarget)) return TRUE;

These were found under a function called AI_ActionCastBackupRandomSpell().

Once removed, the Cleric stopped tossing out unlimited INFLICT_ spells, cast what she had, then equiped a crossbow with poisoned bolts - as expected.

At this point, I'll take it!

FP!
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Jasperre's AI - anyone?
« Reply #6 on: August 30, 2012, 01:19:22 am »


               Congrats - your scripting isnt that bad afterall '<img'>
               
               

               
            

Legacy_Krevett

  • Full Member
  • ***
  • Posts: 203
  • Karma: +0/-0
Jasperre's AI - anyone?
« Reply #7 on: August 30, 2012, 07:04:18 am »


               Hi I'm also having a problem with jasperre AI I made a red dragon and he never use his breath he just cast some spells and sometimes some physical attacks but no breath at all...how dissapointing!
               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Jasperre's AI - anyone?
« Reply #8 on: August 30, 2012, 02:31:48 pm »


               Hi Krevett!

The best suggestion I can give you, is to change the frequency of the Dragon's breath breathing.

SetAIInteger(AI_DRAGON_FREQUENCY_OF_BREATH, 3);
// Min. Amount of Rounds between each breath use. See readme for counter defaults. Def: 3

So every 3 rounds the dragon should breathe, but if you already have this set, then I my other suggestion is to make sure characters that are in the encounter with said dragon, do not have resistances to their type of breath.

From looking through j_ai_generic_ai, Jasperre's AI won't waste using a dragon breath if the character(s) have immunity.

int AI_ActionUseBreath(object oTarget, talent tBreath, int iSpellID)
{
    int iImmune = FALSE;// If TRUE, don't use it it
    // Go through them...
    switch(iSpellID)
    {
        case SPELLABILITY_DRAGON_BREATH_FEAR: iImmune = GetIsImmune(oTarget, IMMUNITY_TYPE_FEAR); break;
        case SPELLABILITY_DRAGON_BREATH_PARALYZE: iImmune = GetIsImmune(oTarget, IMMUNITY_TYPE_PARALYSIS); break;
        case SPELLABILITY_DRAGON_BREATH_SLEEP: iImmune = GetIsImmune(oTarget, IMMUNITY_TYPE_SLEEP); break;
        case SPELLABILITY_DRAGON_BREATH_SLOW: iImmune = GetIsImmune(oTarget, IMMUNITY_TYPE_SLOW); break;
        case SPELLABILITY_DRAGON_BREATH_WEAKEN: iImmune = GetIsImmune(oTarget, IMMUNITY_TYPE_ABILITY_DECREASE); break;
    }
    // Use it!
    if(!iImmune)
    {
        // 35: "[DCR:Dragon] Breath weapon & attacking [Breath ID] " + IntToString(iSpellID) + " [Target] " + GetName(oTarget)
        DebugActionSpeakByInt(35, oTarget, iSpellID);
        ActionUseTalentAtLocation(tBreath, GetLocation(oTarget));
        ActionAttack(oTarget);
        return TRUE;
    }
    return FALSE;
}


FP!
               
               

               


                     Modifié par Fester Pot, 30 août 2012 - 01:37 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Jasperre's AI - anyone?
« Reply #9 on: August 30, 2012, 05:40:54 pm »


               That script should not affect the dragons use of fire, an elemental attack, as it is only checking for incapacitating breaths.  I suppose you could add fire or other elemental breaths to that list, but aren't breaths all cone attacks?  What I am getting at is if only the target is immune to the breath and there are other companions in the area of effect would you not want to check them too before deciding not to use your breath weapon?
               
               

               
            

Legacy_Krevett

  • Full Member
  • ***
  • Posts: 203
  • Karma: +0/-0
Jasperre's AI - anyone?
« Reply #10 on: August 31, 2012, 11:01:31 am »


                For dragons, everything is already set like that, and there was no immunity involved so I don't understand what's going on... Anyway I'm going to switch back to standard AI (I use jasperre only for boss/uniquemonsters) because jasperres on death script also mess up one of my script... I'm building a semi-persistent world for my friends so when a boss is killed he won't respawn even after restarting the server, this works perfect with the standard AI but it doesn't work at all with jasperre (the script just stores an index number and link the tag of the monster killed to this index so that it is destroyed at server reset)
               
               

               
            

Legacy_Krevett

  • Full Member
  • ***
  • Posts: 203
  • Karma: +0/-0
Jasperre's AI - anyone?
« Reply #11 on: August 31, 2012, 12:52:00 pm »


               Persistent death solved by removing corpses from the onspawn settings.

Edit: solved dragon breath it wasn't used in the first few rounds of battle but when the dragon was under half his max hp he used it every three rounds...
               
               

               


                     Modifié par Krevett, 31 août 2012 - 12:13 .