Aller au contenu

Photo

Creature AI - Requires Whole Process Explanation Please. (Expert Advice Required.)


  • Veuillez vous connecter pour répondre
42 réponses à ce sujet

#26
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Pretty sure it has to do with henchspells.2da. Either that or it's hard coded.

This is very near completion but i have not had a chance to try it out in game. Download this program called Never Worker then open henchspells.2da ( use the version in the link as it has the name of the spell added to make things easier ). Make sure you keep a copy of henchspells.2da prior to changing it as this might cause wonkiness. This will show you the hidden "bits" inside the values of this 2da and allow you to edit them. The version of henchspells.2da i am providing has rows for official, kaedrins and the PRC, as well as a lot of custom spells i am doing.

This will require research and testing on the part of the community as figuring that out is too big of a project for me alone ( with everything else i am doing ), as to how much of an effect this 2da has on the AI is very complicated, and very hard to follow even for me. However by providing an editor/viewer i think it's enough on my part for this to get sorted out. Putting things within the realm of more people, why things work and don't work will be a lot easier to discover if you don't have to learn bitwise math to enter in the rules you want. I suspect that acid breath will be something in the henchspells properly while other things are not.

I am going to be doing one for the other 2 hench 2da's that come with the AI next ( and am working on various other 2da's as well ).

Even with this working i think i need to do a new 2da similar to the ones in game which lists all the special abilities just to improve performance and allow better caching.

Please tell me any issues you see with that editor as well, or wonkiness it causes, and anything discovered i can actually put as notes into the interface. How this is set up is VERY complicated and it's hard to know if the values are being retrieved/saved correctly until it's been tested to show a real effect in game, however it technically should be accurate.

#27
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

M. Rieder wrote...

<SNIP>One other question, is "X2_SPECIAL_COMBAT_AI_SCRIPT" the name of a local string stored on a particular creature, with the value of the string being the name of the special script that you want it to run in combat.


Hi Matt,

Yes.

E.g. I currently have "alb_ai_template" as a test as a value inside "X2_SPECIAL_COMBAT_AI_SCRIPT" on a creature. I am making alterations to that script.

Check out "x2_ai_demo" as a starter guide, although their demo line should be TalentFlee(oTarget);

Lance.

#28
kevL

kevL
  • Members
  • 4 052 messages
Tks Pain, henchspells.2da going into my override, now.

M. Rieder wrote...

One other question, is "X2_SPECIAL_COMBAT_AI_SCRIPT" the name of a local string stored on a particular creature, with the value of the string being the name of the special script that you want it to run in combat.

Yes (it looks like, i haven't actually used it yet)

The default DeathKnight ( c_deathknight ) uses this variable on itself, and it fires ' gb_deathknight_ai ' - it does some chooseTactics and also makes a decision on casting a SPELLABILITY_

(note the x2 version of gb_deathknight_ai has been entirely commented out; the x1 version seems it should be operational, go figur).


EDIT, ninja'd !!

Modifié par kevL, 24 mars 2011 - 07:14 .


#29
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

painofdungeoneternal wrote...

<SNIP>

This is very near completion but i have not had a chance to try it out in game. Download this program called Never Worker then open henchspells.2da ( use the version in the link as it has the name of the spell added to make things easier ). Make sure you keep a copy of henchspells.2da prior to changing it as this might cause wonkiness. This will show you the hidden "bits" inside the values of this 2da and allow you to edit them. The version of henchspells.2da i am providing has rows for official, kaedrins and the PRC, as well as a lot of custom spells i am doing.<SNIP>


Thanks for providing this Pain.

I am still navigating the basics at the moment, but once I get a better feel of things, I will try to have a look with your prog and let you know.

At the moment, just getting to grips with the basics of AI and substitute scripts is an uphill struggle.

I think I may be at the top now though.

Lance.

Modifié par Lance Botelle, 24 mars 2011 - 07:47 .


#30
kevL

kevL
  • Members
  • 4 052 messages
Pain,

just noticed the first row of henchspells.2da (above) is:

2DA V2.0 V2.0

it wouldn't open in .2da editors .. took off the 2nd 'V2.0' and its all good again


heads up for ya?



Lance, any relation? A distant cousin perhaps ;)
jK!

#31
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

kevL wrote...

<SNIP>Lance, any relation? A distant cousin perhaps ;) jK!


Hi KevL,

That bunny is far too aggressive for Honey (my upstairs bunny and used as my avatar), but could well be related to Daisy (one of our downstairs bunnies) - she can be ready to defend herself if you upset her at all. We call her "Crazy Daisy", but she is still adorable.

Lance.

#32
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
ah k, will look a that. Which is why i made my own editor, it should ignore anything after the first 2.0 just like the game does.

( most likely when i used excel to add the label column which i bet also copied 2 of that version, my editor should fix that once it gets saved as it removes anything not following the spec, i've been not saving that file as i am still testing that the values round trip right. If a 2da won't open in another editor, there is a good chance just opening it and saving it again with my program will make it work with other programs. ( part of why it takes so long to load is it's not taking any shortcuts and parsing character by character )

I really need to compile a listing of what all the variables are from the perspective of the AI scripts ( so nothing is missed ) written in a way that shows how you can use them in toolset as variables on npc's to adjust behavior. There is the master flag which is used for a lot of things, the special ai script flag, and ones to determine if they cast spells, shoot arrows or prefer to enter into melee.

Edit: reuploaded, yep all i had to do was open it in never worker and save it again. It was definitely an issue when i used excel to add a column in the middle.

Modifié par painofdungeoneternal, 24 mars 2011 - 08:07 .


#33
kevL

kevL
  • Members
  • 4 052 messages
nice, guys

back to Factioning ..

#34
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

painofdungeoneternal wrote...

<SNIP>Edit: reuploaded, yep all i had to do was open it in never worker and save it again. It was definitely an issue when i used excel to add a column in the middle.


Hi Pain,

That's better ... :)

Lance.

EDIT: I opened your prog and took a quick look at the 2da file, but it's not something that I really understand at the moment. Maybe it's something I can ask about if and when the time comes ... and you are able to explain how it actually translates into what happens in game. I know it's early days yet, so no worries for now. Posted Image

Modifié par Lance Botelle, 24 mars 2011 - 09:19 .


#35
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
It uses the description of the spell / abiltiy to know where and when to use it.

If it needs a death spell, it looks for the death checkmark. It has an over all category, level of hte spell, estimation of damage. When you decide to cast fire ball, you think hmm i need a third level fire damage aoe spell, hmm fire ball does 1d6 per level capping at level 10, is a reflex save. These opponents have poor reflex saves.

That file is how the AI relates what you remember ( the facts ) with the situation, so it can make a proper choice of what spell to use. If it can't find that info, it just chooses to hit you with a club.

If you have a ability which is not working, find a similar row and copy the values its using ( ie if it's a fire type thing copy fire ball ), then adjust some of the menu items which obviously seem wrong. The integers this all uses ( 5 of them per row ) are all that has to be copied, all those menus fields and checkboxes are just editing those on the fly.

As for explaining it, lol you are kidding right. Beyond just filling it out, i have no idea which of those menu items is important at this point, or what each thing does, any more than i could describe how the AI works. I am hoping someone can look at this and explain it to me. I am really hoping just filling it out and correcting what does not seem to make sense will just happen to fix things in game.

Modifié par painofdungeoneternal, 24 mars 2011 - 09:30 .


#36
The Fred

The Fred
  • Members
  • 2 516 messages

kevL wrote...
it wouldn't open in .2da editors ..

Notepad!

#37
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

painofdungeoneternal wrote...

It uses the description of the spell / abiltiy to know where and when to use it.

If it needs a death spell, it looks for the death checkmark. It has an over all category, level of hte spell, estimation of damage. When you decide to cast fire ball, you think hmm i need a third level fire damage aoe spell, hmm fire ball does 1d6 per level capping at level 10, is a reflex save. These opponents have poor reflex saves.

That file is how the AI relates what you remember ( the facts ) with the situation, so it can make a proper choice of what spell to use. If it can't find that info, it just chooses to hit you with a club.

If you have a ability which is not working, find a similar row and copy the values its using ( ie if it's a fire type thing copy fire ball ), then adjust some of the menu items which obviously seem wrong. The integers this all uses ( 5 of them per row ) are all that has to be copied, all those menus fields and checkboxes are just editing those on the fly.

As for explaining it, lol you are kidding right. Beyond just filling it out, i have no idea which of those menu items is important at this point, or what each thing does, any more than i could describe how the AI works. I am hoping someone can look at this and explain it to me. I am really hoping just filling it out and correcting what does not seem to make sense will just happen to fix things in game.



Hi Pain,

Posted Image I was too scared to edit anything without knowing ... I did not know you were feeling the same. Posted Image

Editing these figures is definitely something to do later down the line then .... Posted Image

In the meanwhile, I also found these constants that can be added and may have an impact ...

const string sCombatCondVarname = "X0_COMBAT_CONDITION";
const int X0_COMBAT_FLAG_RANGED            = 0x00000001;
const int X0_COMBAT_FLAG_DEFENSIVE         = 0x00000002;
const int X0_COMBAT_FLAG_COWARDLY          = 0x00000004;
const int X0_COMBAT_FLAG_AMBUSHER          = 0x00000008;

Once I have tracked down all the valid conditions, I will consider listing all the useful ones (and where they are found) and possibly putting a small AI manual together ... if I get that far.  Posted Image

Lance.

EDIT: Regarding animations, do the SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS); and SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS); do anything extra than we already see on the creatures in the way of animations then?

Modifié par Lance Botelle, 24 mars 2011 - 10:59 .


#38
kevL

kevL
  • Members
  • 4 052 messages
hi Fred, jah notepad did the trick!
so did NeverWorker (love that name ..)

gonna piggyback - again - and point out that if anyone is using TonyK's in their override, they're using older versions of hench*.2da. Those should be renamed, as newer ones become available here & there, i'm assuming.

I'm looking forward to this, but duplicate files by mistake can't help



( let it sink in )

here's a *cough* realworld example ..

I'm building a temple interior that has 3 Defenders and 5 Commoners, and decided to see what happens when a group of Hostile undead spawns in the middle of them. The AI is actually pretty good, though it leaves a lot to be desired. The Priestess (Defender) turns undead right away if the opponents' levels are low enough (where is that decided); the 2 Fighter Defenders go into action as expected; and the Commoners all run away, with undead on their heels (i wonder if that has something to do with X0_COMBAT_FLAG_COWARDLY). Now that I have the Faction table worked out to my satisfaction, I see that the Priestess weights her spell-casting vastly in favor of offensive spells, which in this case is inarguably not the right thing to do. She's pretty good with trying not to blast her allies with AoE's, uses Hammer of the Gods repeatedly although it's not very good against undead that're immune to Mind Affecting spells, but won't do stupid things like Slay Living (which she used against my PC with terrible effect) or Inflict spells - she will use Inflict against my PC, however. She does good with healing her allies if she has a spare moment or three, has been using Blindness against my PC, but doesn't seem to be casting buffs on her allies like Magic Weapon, or even a Magic Circle against Alignment (evil). I'd like to see her Prayer cast sooner, rather than after more than 5 rounds (Bless, Mass Aid, etc.), and Divine Power should be more closely integrated into her decision to go to melee attacks. Making any decision to back off again and resume casting would prob'ly be more difficult.

i'm not asking for fixes here, just giving an idea of what's being worked with ..

Lance Botelle wrote...

EDIT: Regarding animations, do the SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS); and SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS); do anything extra than we already see on the creatures in the way of animations then?

This is actually what brought me into looking at the AI. When I place down an NPC, he/she kinda stands there and sways around, and occasionally does a "what's that!" stance. But that's it; no head scratching, no ranting, waving, or chatting up the neighbors. With NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS those things happen every few rounds (my Priestess even does some praying and worshipping at her NW_ALTAR (tag of altar). NW_FLAG_AMBIENT_ANIMATIONS is kinda goofy, they'll wander around aimlessly and end up facing the wall (a few NW_STOP waypoints seemed to help), but they get into good conversations with their neighbors with that one. Sometimes I watch them and wish I could hear what they're saying ...

The problem was, if you set the string variable on the NPC, and use the default onSpawn, which triggers WalkWayPoints(), as can the onHeartbeat (seems to set the flag for NW_WALK_FLAG_CONSTANT), then the code in the HeartBeat that triggers the animations never fires. Personally I ended up debugging the onHeartbeat script, Lance: you could move the else if (GetWalkCondition(NW_WALK_FLAG_CONSTANT)) from above to below the else directly beneath it, and change the latter to

else if (GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS | NW_FLAG_AMBIENT_ANIMATIONS_AVIAN) ||
(GetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS) &&
GetIsObjectValid(oPost) && GetDistanceToObject(oPost) < 0.5f &&
GetFacing(oPost) == GetFacing(OBJECT_SELF)))

this way if they're at their post they do Immobile Animations, or are doing Ambient walking, and the WalkWayPoints() never never needs to fire (unless they leave or get bumped off their posts somehow). This uses the assumption that creatures walking a sequence of waypoints would never do animations, anyway.


In the meanwhile, I also found these constants that can be added and may have an impact ...

Pain has pointed out some major includes in the other thread; just a reminder here that there is a template script ' Custom OnSpawn.nss ' (which may be where you got these COMBAT_FLAGs) .. idk! ps. Say hi to Daisy fer me

#39
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

kevL wrote...

here's a *cough* realworld example ..

I'm building a temple interior that has 3 Defenders and 5 Commoners, and decided to see what happens when a group of Hostile undead spawns in the middle of them. The AI is actually pretty good, though it leaves a lot to be desired. The Priestess (Defender) turns undead right away if the opponents' levels are low enough (where is that decided); the 2 Fighter Defenders go into action as expected; and the Commoners all run away, with undead on their heels (i wonder if that has something to do with X0_COMBAT_FLAG_COWARDLY). Now that I have the Faction table worked out to my satisfaction, I see that the Priestess weights her spell-casting vastly in favor of offensive spells, which in this case is inarguably not the right thing to do. She's pretty good with trying not to blast her allies with AoE's, uses Hammer of the Gods repeatedly although it's not very good against undead that're immune to Mind Affecting spells, but won't do stupid things like Slay Living (which she used against my PC with terrible effect) or Inflict spells - she will use Inflict against my PC, however. She does good with healing her allies if she has a spare moment or three, has been using Blindness against my PC, but doesn't seem to be casting buffs on her allies like Magic Weapon, or even a Magic Circle against Alignment (evil). I'd like to see her Prayer cast sooner, rather than after more than 5 rounds (Bless, Mass Aid, etc.), and Divine Power should be more closely integrated into her decision to go to melee attacks. Making any decision to back off again and resume casting would prob'ly be more difficult.


That all sounds quite promising actually.



This is actually what brought me into looking at the AI. When I place down an NPC, he/she kinda stands there and sways around, and occasionally does a "what's that!" stance. But that's it; no head scratching, no ranting, waving, or chatting up the neighbors. With NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS those things happen every few rounds (my Priestess even does some praying and worshipping at her NW_ALTAR (tag of altar). NW_FLAG_AMBIENT_ANIMATIONS is kinda goofy, they'll wander around aimlessly and end up facing the wall (a few NW_STOP waypoints seemed to help), but they get into good conversations with their neighbors with that one. Sometimes I watch them and wish I could hear what they're saying ...

I will experiment some more with these then .... I also just asked about this in the other thread, so maybe I have some double feedback.



Pain has pointed out some major includes in the other thread; just a reminder here that there is a template script ' Custom OnSpawn.nss ' (which may be where you got these COMBAT_FLAGs) ..

Yes, I just caught up with this, but was aware of this script already. Posted Image The list of FLAGS comes from the X0_I0_SPAWNCOND script.



Say hi to Daisy fer me

Check out Daisy in a crazy moment .... Plenty more pictures there too

Lance.

Modifié par Lance Botelle, 25 mars 2011 - 01:21 .


#40
kevL

kevL
  • Members
  • 4 052 messages
Daisy ! - that's amazing :)

#41
kevL

kevL
  • Members
  • 4 052 messages

painofdungeoneternal wrote...

henchspells.2da

Is it my imagination, or are enemy casters *way* more smart?

I've been playing SoZ with this. Unfortunately I haven't played SoZ for a long while and so don't have much to compare enemy spellcasting with, other than MotB, which before P's henchspells.2da was a nearly constant stream of Dispel Magic, Dispel Magic, Dispel Magic ..

What i am experiencing is either a better design of say, Orc Shaman in SoZ or the new henchspells.2da : Fireball, Ice Storm, Ice Storm, Ice Storm, heal, buff, Inflict Wounds ............


anyway, back to whats important.

Modifié par kevL, 12 avril 2011 - 12:31 .


#42
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
not my work, that is all Tony K's.

My goal there is to make the NPC's understand custom content, and for established spells for the community to be able to review current values for errors. And of course point people at this thing which is relatively easy to change, instead of doing a new AI for each creature.

Modifié par painofdungeoneternal, 12 avril 2011 - 01:05 .


#43
kevL

kevL
  • Members
  • 4 052 messages
hi Pain,

ah, i See. just did a compare (which i shoulda done before) and aside from the extra columns and rows, Yes it matches TK's. So I guess it's safe to assume the enemy casters are better designed - with more spell selection - in SoZ, or its my imagination!


having some great fights and can't turn my back on those s*ckers.