Author Topic: Allegiance in AI Scripting  (Read 2550 times)

Offline icelus

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3173
  • Gender: Male
Allegiance in AI Scripting
« on: August 01, 2004, 08:22:43 PM »
Could someone please explain to me (preferably as if to a 5 year old) what GOODCUTOFF and EVILCUTOFF really mean? 
« Last Edit: August 01, 2004, 08:30:39 PM by icelus »
<Moongaze> Luckily BWL has a very understanding and friendly admin.

Offline icelus

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3173
  • Gender: Male
Re: Allegiance in AI Scripting
« Reply #1 on: August 01, 2004, 08:24:41 PM »
It's for allegiance, and covers anything with X in the name.

i.e. GOODBUTBLUE, GOODBUTRED, and FAMILIAR are all considered GOODCUTOFF.

Let me dig out my ea.ids and split it up for you...

10
1 INANIMATE
2 PC                       good guy
3 FAMILIAR                       good guy
4 ALLY                     good guy
5 CONTROLLED                     good guy
6 CHARMED                     good guy
28 GOODBUTRED                     good guy
29 GOODBUTBLUE                     good guy
30 GOODCUTOFF                     good guy
31 NOTGOOD
126 ANYTHING
128 NEUTRAL
199 NOTEVIL
200 EVILCUTOFF                     evil guy
201 EVILBUTGREEN                     evil guy
202 EVILBUTBLUE                     evil guy
255 ENEMY                     evil guy


It's useful for having fights between you and some blue-circled allies, say, and a band of bad guys who are red circled.  The allies would be GOODBUTBLUE, and the bad guys would target GOODCUTOFF, being either summoned party monsters, the party, or the blue-circled allies.
« Last Edit: August 01, 2004, 08:31:05 PM by icelus »
<Moongaze> Luckily BWL has a very understanding and friendly admin.

Offline icelus

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3173
  • Gender: Male
Re: Allegiance in AI Scripting
« Reply #2 on: August 01, 2004, 08:25:29 PM »
So GOODCUTOFF is basically everything above itself, and EVILCUTOFF is everything below itself?

« Last Edit: August 01, 2004, 08:31:26 PM by icelus »
<Moongaze> Luckily BWL has a very understanding and friendly admin.

Offline icelus

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3173
  • Gender: Male
Re: Allegiance in AI Scripting
« Reply #3 on: August 01, 2004, 08:26:12 PM »
Except Inanimate.  Not sure what that's for.  Maybe things like statues and doors?
« Last Edit: August 01, 2004, 08:31:46 PM by icelus »
<Moongaze> Luckily BWL has a very understanding and friendly admin.

Offline icelus

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3173
  • Gender: Male
Re: Allegiance in AI Scripting
« Reply #4 on: August 01, 2004, 08:27:39 PM »
After trying to figure this out on my own for a few days, I give up!  I need help!   

Cailean comes equipped with a bow, some arrows, an axe and a short sword.  After casting (or attempting to cast) Armor of Faith and quaffing a potion of speed, he eventually gets around to firing some arrows at BH2.  BH1 comes up and back stabs him (a second time) and Cailean switches to axe.  He then whittles away at BH1.  He doesn't ever move away and switch back to bow.  If he does manage to kill BH1, he just stands around occasionally switching between bow and axe while BH2 stabs him.  This all happens pre-joining.  Cailean is blue circled neutral and BH1 & 2 start blue circled and then after some dialog, turn to red circled enemey().

Here's the code that I'm using, a lot of it was quite shamelessly stolen from SimDing0. :)

Code: [Select]
IF
    Global("FWCaileanBH1Fight","GLOBAL",2)
    See(Player1)
    Global("FWCaileanJoined","LOCALS",0)
    GlobalGT("SPRITE_IS_DEADFWCaiBH1","GLOBAL",0)
    GlobalGT("SPRITE_IS_DEADFWCaiBH2","GLOBAL",0)
    CombatCounter(0)
THEN
    RESPONSE #100
        SetGlobal("FWCaileanJoined","LOCALS",1)
        Dialogue(Player1)
END

IF
  GlobalLT("FWCaileanBH1Fight","GLOBAL",2)
THEN
  RESPONSE #100
    NoAction()
END

IF
  Global("FWCaileanBH1Fight","GLOBAL",2)
  HaveSpell(CLERIC_ARMOR_OF_FAITH)
THEN
  RESPONSE #100
    Spell(Myself,CLERIC_ARMOR_OF_FAITH)
END

IF
  HPPercentLT(Myself,40)
  HasItem("POTN52",Myself)  // ~Potion of Extra Healing~
THEN
  RESPONSE #100
    DisplayStringHead(Myself,46150)  // ~quaffs a potion~
    UseItem("POTN52",Myself)  // ~Potion of Extra Healing~
END

IF
  !StateCheck(Myself,STATE_HASTED)
  HasItem("POTN14",Myself)
THEN
  RESPONSE #100
    DisplayStringHead(Myself,46150)  // ~quaffs a potion~
    UseItem("POTN14",Myself)
END

IF
    Global("FWCaiEnemyNearby","LOCALS",0)
    Range(NearestEnemyOf(Myself),10)
THEN
    RESPONSE #100
        SetGlobal("FWCaiEnemyNearby","LOCALS",1)
        Continue()
END

IF
    Global("FWCaiEnemyNearby","LOCALS",1)
    !Range(NearestEnemyOf(Myself),10)
THEN
    RESPONSE #100
        SetGlobal("FWCaiEnemyNearby","LOCALS",0)
        Continue()
END

IF
  OR(3)
    See(NearestEnemyOfType([EVILCUTOFF]))
    See("FWCaiBH2")
    See("FWCaiBH1")
  False()
THEN
  RESPONSE #100
END

IF
    OR(4)
      StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
      StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
      StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
      StateCheck(LastSeenBy(Myself),STATE_PANIC)
    Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
    RESPONSE #100
        Attack(LastSeenBy(Myself))
END


IF
    Allegiance(LastSeenBy(Myself),EVILCUTOFF) // Check the target is an enemy
    Range(LastSeenBy(Myself),10) // If the target is nearby (no need to check for other nearby enemies if the target is near)
THEN
    RESPONSE #100
        EquipMostDamagingMelee() // Switch to a melee weapon
        AttackReevaluate(LastSeenBy(Myself),45) // Attack the target
    RESPONSE #10
        EquipRanged() // Switch to a ranged weapon
        RunAwayFrom(LastSeenBy(Myself),75)
END

// This block will execute if the target is far away, but an enemy is near
IF
    Allegiance(LastSeenBy(Myself),EVILCUTOFF) // Check the target is an enemy
    !Range(LastSeenBy(Myself),10) // If the target is far away
    Global("FWCaiEnemyNearby","LOCALS",1) // If an enemy is nearby
THEN
    RESPONSE #100
        EquipRanged() // Equip a ranged weapon
        RunAwayFrom(NearestEnemyOf(Myself),75) // Run away from the nearby enemy
    RESPONSE #100
        EquipMostDamagingMelee() // Equip a melee weapon
        AttackReevaluate(LastSeenBy(Myself),45) // Attack the nearby enemy
    RESPONSE #10
        EquipRanged() // Equip a ranged weapon
        AttackReevaluate(LastSeenBy(Myself),45) // Attack the target
END

// This block will execute if the target is far away, and there are no enemies nearby
IF
    Allegiance(LastSeenBy(Myself),EVILCUTOFF) // Check the target is an enemy
    !Range(LastSeenBy(Myself),10) // If the target is far away
    HaveSpell(ARCHER_CALL_SHOT)
    Global("FWCaiEnemyNearby","LOCALS",0) // If no enemy is nearby
THEN
    RESPONSE #100
        EquipRanged() // Equip a ranged weapon
        Spell(Myself,ARCHER_CALL_SHOT)
        AttackReevaluate(LastSeenBy(Myself),45) // Attack the target
    RESPONSE #10
        Continue() // Continue to the random walking block
END

IF
    Allegiance(LastSeenBy(Myself),EVILCUTOFF) // Check the target is an enemy
    !Range(LastSeenBy(Myself),10) // If the target is far away
    !HaveSpell(ARCHER_CALL_SHOT)
    Global("FWCaiEnemyNearby","LOCALS",0) // If no enemy is nearby
THEN
    RESPONSE #100
        EquipRanged() // Equip a ranged weapon
        AttackReevaluate(LastSeenBy(Myself),45) // Attack the target
    RESPONSE #10
        Continue() // Continue to the random walking block
END

IF
    True() // If nothing above has been executed
THEN
    RESPONSE #100
        EquipRanged() // Equip a ranged weapon
        RandomWalkContinuous() // Move around
END
« Last Edit: August 01, 2004, 08:32:05 PM by icelus »
<Moongaze> Luckily BWL has a very understanding and friendly admin.

Offline icelus

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3173
  • Gender: Male
Re: Allegiance in AI Scripting
« Reply #5 on: August 01, 2004, 08:30:11 PM »
Well I figured it out.  I was being too specific in the targeting.  I ended up getting rid of the DVs and just left in [EVILCUTOFF] and it worked much better!
<Moongaze> Luckily BWL has a very understanding and friendly admin.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: