Mob Brains and Controlled Brains

For any problems with Dawn of Light website or game server, please direct questions and problems here.

Moderator: Support Team

Mob Brains and Controlled Brains

Postby Leodagan » Thu Sep 05, 2013 5:43 pm

I have strange behavior with a "naburite drinker"

This mob is from live DAOC (agramon/darkness fall) and I've set his spells npctemplate to a low level Bonedancer instant drain...

The instant drain should be on a 8 sec recast timer

When the mob is wild, he never use it ! I wonder what kind of spells mobs can cast and why he doesn't cast this once...

When the mob is charmed it's funnier, he chain this spell over and over and rush to melee continuing to cast in fight !

It makes a wonderful pet !

Is it the wrong way to implement this kind of mob insta skills ? should mobs only use "styles" for insta cast or in fight effects ? Should I look at brain were it says that it shouldn't be edited lightly to change mobs behavior ? (this charmed mob could at least use the recast delay...)

Thx for any help ;)
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Mob Brains and Controlled Brains

Postby Graveen » Thu Sep 05, 2013 6:55 pm

IIRC DF mobs are not charmables except necyos :) but there is obviously a bug in the code, either because the spell is not fired or fired too often.

For the spell fired too often it can comes from the think interval chaining this spell without respecting the timer.
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Mob Brains and Controlled Brains

Postby Leodagan » Thu Sep 05, 2013 7:34 pm

It looks faster than think interval, which should be 1.5 sec, I didn't think of timing it... I'll say it's every seconds or less (well now it may be my serverproperty that lowered this, I want entertaining mobs !)

But well I began to search in Controlled Brain and now I understand the warnings ! When reading this and having in mind to change anything I heard Moss from IT Crowd yelling "You're killing the rainforest !"

I'll have to understand this code before editing it ! (And it really LACKS comments...)
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Mob Brains and Controlled Brains

Postby Leodagan » Thu Sep 05, 2013 9:05 pm

After looking around code that make me think it's going somewhere around there.

I think it's maybe not Brain related, there is code to check GetSkillDisabledDuration(spell), I don't know if it's what it's meant to be, but looks like a timer for recast...

I'll look around spell handler
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Mob Brains and Controlled Brains

Postby Leodagan » Fri Sep 06, 2013 4:43 am

Recast Delay is handled at really low level of Spell Handler, and it applies correctly recast delay to "GameLiving"...

I was expecting a bug with GameLiving being cast to GamePlayer or checked as GamePlayer before applying delay !

I get back to brains...
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Mob Brains and Controlled Brains

Postby Leodagan » Fri Sep 06, 2013 9:07 am

Ok I didn't find anything for my trouble right now, but I'm looking around different Brains code...

It looks like most of these codes could need an update, we are far from standards AI Algorithm !

I worked on Chess games AI and did some theoretical research on this while in university, I don't have much memories of these, but I remember basic AI Algorithm should use either a solution Tree (from initial state to best solution, then play the path), or a MIN_MAX algorithm (give some points to every actions depending on their effect, play the action with best score or a random one with a good score)

And I'm not talking about complexity ! These algorithms are pretty lights, until you use them in a recursive procedure that take the resulting best solution as next initial state (in chess it can guess other player next move, based on his own algorithm to tell best move he would play, after 4 or 5 recursions your CPU end up working for hours ! but it's the only way to make an entertaining chess bot, or he won't make any strategies...)

I got the feeling that current brains just do what they CAN do, not what they SHOULD do ! But I've been warned that mobs behavior shouldn't be improved too much or they could get really hard to fight ! As I understand Brain code, Every "Think" the NPC choose an action to do if he isn't doing something inappropriate (like being rupt, or told to go somewhere), and then use this action

I don't see any queues either that should be used to build strategies, even if a Think Interval goes into an appropriate state (iscasting) it will just wait next Think to decide what to do, it could use this "blank" think to update current state of fight and queue next move !
Last edited by Leodagan on Fri Sep 06, 2013 1:18 pm, edited 1 time in total.
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Mob Brains and Controlled Brains

Postby Tolakram » Fri Sep 06, 2013 12:29 pm

There is a re-write of the brain code in progress but stopped due to the amount of work involved.

My suggestion is either take over that code or start your own brains, get them working, and once tested mobs can be assigned the new brain. You can create your own mob type to use these brains for testing. Brain code is intertwined with GameLiving code to such an extent that any changes to it will require an extreme makeover. You will break stuff that you never knew could be broken. :)

Fair warning.

As for your spell casting issue, note that the controlled brain and standard mob brain only knows about so many spell types and will ignore others. You also need to follow the casting sequence, usually with log.debug statements, so you understand the spell timing sequence and why and where spells are getting stuck. If your brain thinks to fast, for example, the spell might be getting stopped and replaced before it can cast.

Good luck :)
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: Mob Brains and Controlled Brains

Postby Leodagan » Fri Sep 06, 2013 1:16 pm

Thx for your comment, I've seen that brain use a lot of GameLiving, but it seems ok to me, I expect problem with race conditions by trying to touch anything, and it isn't clear in code when something is a "workaround" or really a game mechanics...

There are some code that looks completely wrong when you read it, and when beginning to trace the execution you understand they are side-effects that prevent race conditions (like target changed...)

Anyway a player helped me by telling me "charmed" mob doesn't cast this insta spell when target has buffs/debuffs (which I had as a caster with self-AF)

And it made me look there :

StandardMobBrain.cs
Code: Select all
protected bool LivingHasEffect(GameLiving target, Spell spell) { if (target == null) return true; if (target is GamePlayer && (target as GamePlayer).CharacterClass.ID == (int)eCharacterClass.Vampiir) { switch (spell.SpellType) { case "StrengthConstitutionBuff": case "DexterityQuicknessBuff": case "StrengthBuff": case "DexterityBuff": case "ConstitutionBuff": case "AcuityBuff": return true; } } lock (target.EffectList) { //Check through each effect in the target's effect list foreach (IGameEffect effect in target.EffectList) { //If the effect we are checking is not a gamespelleffect keep going if (effect is GameSpellEffect == false) continue; GameSpellEffect speffect = effect as GameSpellEffect; //if the effect effectgroup is the same as the checking spells effectgroup then these are considered the same if (speffect.Spell.EffectGroup == spell.EffectGroup) return true; //otherwise continue unless the SpellType is the same if (speffect.Spell.SpellType == spell.SpellType) return true; } }
The EffectGroup check doesn't "continue" on spell with EffectGroup NULL value ! If I understand right, the dbSpell object will put "0" in this int value when database value is "NULL" ? and then all spell with NULL value in EffectGroup will match themselves (that's not SQL behavior, NULL == NULL should return false !)

That doesn't solve the controlled brain spam casting, but I'm getting near !


And I did read your warning on Brains somewhere else, I still had it in mind, I haven't enough time for a complete rewrite for now, but I will do something about that !
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Mob Brains and Controlled Brains

Postby Leodagan » Fri Sep 06, 2013 4:38 pm

Well I found something else :

StandardMobBrain.CheckInstantSpells() which is used by ControlledNpcBrain to cast spells, is never used by StandardMobBrain itself...

It's used by TheurgistPet. and overriden by BD Pets.

So this proc in StandardMobBrain is only used by ControlledNpc Classes...

So that's not the place to check how instant spells are handled by "wild" uncontrolled mob !!
Last edited by Leodagan on Fri Sep 06, 2013 4:53 pm, edited 1 time in total.
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Mob Brains and Controlled Brains

Postby Tolakram » Fri Sep 06, 2013 4:45 pm

Sure it is. Look at SMB Think() and follow it through.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: Mob Brains and Controlled Brains

Postby Leodagan » Fri Sep 06, 2013 4:54 pm

Wrong copy/paste >_< i updated it, I meant StandardMobBrain.CheckInstantSpells() is used by subclass of ControlledNpcBrain and not standard brain itself...
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Mob Brains and Controlled Brains

Postby Graveen » Fri Sep 06, 2013 5:20 pm

Yes, brains are doing what they can, you have pointed it right.

A rewrite of the brain should be somewhere in the Brain folder, but as you can imagine, not totally working.
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Mob Brains and Controlled Brains

Postby Leodagan » Fri Sep 06, 2013 5:41 pm

I'm not just pointing it to spit on it, I'm making notes for later reads :)

For now I'm trying to solve my insta cast problem.

"Checking spells" is area where Controlled brain and Standard Brain aren't doing the same thing so I try to see if there is something wrong around these calls...

And if any other subclass use this with success and how... seeing Theurgist pet use the same code make me wonder why they don't spam instas stun

Finding something about a small bug like that could maybe improve greatly this brain capabilities :) (or at least my knowledge of it)

Sorry if It looks like I'm telling it's crap, my only purpose is really to improve any part I can.

And I think Mark is right, this will need a special debug console, there are much eventhandler, timers, and differents states that can't be predicted easily.

Update : Controlled Pet Command "STAY" is reset every time I try to use it, it happen with charmed mob and enchanter pet, I think I'm gonna check SVN log on this, i've seen this work flawless on other shard... or it's reducing too much pet thinking interval ?
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Mob Brains and Controlled Brains

Postby Graveen » Fri Sep 06, 2013 6:36 pm

No it does not look like you are telling it is crap, you are pointing the complexity of the brain code, which is real.
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Mob Brains and Controlled Brains

Postby Leodagan » Fri Sep 06, 2013 7:41 pm

Someone must have gone through what I'm going !

I've seen in SMB, in the CheckSpells() proc, that it is adding spells to a list for random cast from a non-controlled NPC
Code: Select all
if (Body.GetSkillDisabledDuration(spell) == 0) { if (spell.CastTime > 0) //removed this { if (spell.Target.ToLower() == "enemy" || spell.Target.ToLower() == "area" || spell.Target.ToLower() == "cone") spell_rec.Add(spell); // here the spell is added to casting list }
It only adds spell that have a cast time !

I removed this "IF" statement, and got back the behavior of the Controlled NPC Brain, the mob was spamming insta drain, like when controlled !

At least I understand where are the part that were different between those two Brain :)

And for Theurgist Pet I tracked down the Air Spirit behavior, it launch an insta cast self offensiveproc spell which stuns

That what I thought should be done with this naburite drinker, when asking if it should only use "styles" or similar :)

The good thing in using a insta proc is that it will be spam at summon :D With "Same Effect" Check after first landing, the self buff shouldn't be used anymore, and then you can choose the Proc rate just by editing this spell and/or subspell :)
Great way to implement Theurg spirit with current behavior !

But now I think I've got to check why the recast delay isn't used around : Body.GetSkillDisabledDuration(spell)
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon


Return to “%s” Support

Who is online

Users browsing this forum: No registered users and 1 guest