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

Re: Mob Brains and Controlled Brains

Postby ontheDOL » Sun May 07, 2017 8:32 pm

bit of a gravedigger post here... @ Leodagan , just wondering, is there any reason you didnt commit the controllednpcbrain patch? I just found out about this Stay / Follow bug when i was testing a cabalist.
Started digging code then found this post! Glad I did.
- Unty -
Model Showroom and DOL guides
http://losojos-001-site1.btempurl.com
User avatar
ontheDOL
Developer
 
Posts: 311
Joined: Fri May 20, 2016 4:21 am
Location: Australian abroad

Re: Mob Brains and Controlled Brains

Postby Leodagan » Mon May 08, 2017 5:37 am

This is pretty old :)

I think I wasn't very skilled with DOL back then and I tried to keep away from breaking brains :D

But reading back this thread I did made some update to Disabled Skills in GameLiving that made it to DOL Core !

Judging from my last post I think I tried to rewrite a stub "Mob Brain" and never finished it (some kind of developer way to completely lose focus on the original target...)
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 ontheDOL » Mon May 08, 2017 8:02 pm

well it's a nice fix for pets, i cant believe no one else has mentioned it in the years since then lol (that I could see)
- Unty -
Model Showroom and DOL guides
http://losojos-001-site1.btempurl.com
User avatar
ontheDOL
Developer
 
Posts: 311
Joined: Fri May 20, 2016 4:21 am
Location: Australian abroad

Re: Mob Brains and Controlled Brains

Postby elcotek » Tue May 09, 2017 6:34 am

I use this solution on my server to prvent monsers of spamming casts on targets:
If an effect is active on target the monster will stop casting and repeat if the spell is ended.
This looks ugly but it works for first.
This works for close range and ranged spells and two spells (one near and one ranged) type can be active in same time on the target.
I have many more custom code in my brains, spellhandlers++, for monsters own pets etc++
But they are to mutch changes on my side to bring this on dol source
Code: Select all
/// <summary> /// Checks if any spells need casting /// </summary> /// <param name="type">Which type should we go through and check for?</param> /// <returns></returns> public virtual bool CheckSpells(eCheckSpellType type) { if (Body.IsCasting) return true; if (Body is TheurgistPet == false) //By elcotek monsters cast only if spell not active on Target if (Body.TargetObject != null) { living = Body.TargetObject as GameLiving; } bool casted = false; //Find an active effect GameSpellEffect DamageOverTime = SpellHandler.FindEffectOnTarget(living, "DamageOverTime"); GameSpellEffect Nearsight = SpellHandler.FindEffectOnTarget(living, "Nearsight"); GameSpellEffect Mesmerize = SpellHandler.FindEffectOnTarget(living, "Mesmerize"); GameSpellEffect Disease = SpellHandler.FindEffectOnTarget(living, "Disease"); GameSpellAndImmunityEffect MesmerizeImmunity = SpellHandler.FindImmunityEffectOnTarget(living, typeof(MesmerizeSpellHandler)); GameSpellAndImmunityEffect PoisonImmunity = SpellHandler.FindImmunityEffectOnTarget(living, typeof(DirectDamagePoisoneSpellHandler)); GameSpellAndImmunityEffect DamageOverTimeImmunity = SpellHandler.FindImmunityEffectOnTarget(living, typeof(DirectDamageSpellHandler)); GameSpellAndImmunityEffect DiseaseImmunity = SpellHandler.FindImmunityEffectOnTarget(living, typeof(DiseaseSpellHandler)); GameSpellAndImmunityEffect NearsightImmunity = SpellHandler.FindImmunityEffectOnTarget(living, typeof(NearsightSpellHandler)); if (PoisonImmunity == null && Nearsight == null && NearsightImmunity == null && Disease == null && DiseaseImmunity == null && DamageOverTime == null && DamageOverTimeImmunity == null && MesmerizeImmunity == null && Body != null && Body.Spells != null && Body.Spells.Count > 0 && !Body.IsBeingInterrupted && Mesmerize == null || Nearsight == null && NearsightImmunity == null && PoisonImmunity == null && Disease == null && DiseaseImmunity == null && DamageOverTime == null && DamageOverTimeImmunity == null && MesmerizeImmunity == null && Mesmerize == null && Body != null && Body.Spells != null && Body.Spells.Count > 0 && Body.IsWithinRadius(Body.TargetObject, 400)) { ArrayList spell_rec = new ArrayList(); Spell tire = null; bool needpet = false; bool needheal = false; if (type == eCheckSpellType.Defensive) { foreach (Spell spell in Body.Spells) { if (spell == null) continue;//bugfix if (Body.GetSkillDisabledDuration(spell) > 0) continue; if (spell.Target.ToLower() == "enemy" || spell.Target.ToLower() == "area" || spell.Target.ToLower() == "cone") continue; // If we have no pets if (Body.ControlledBrain == null) { if (spell.SpellType.ToLower() == "pet") continue; //pets if (spell.SpellType.ToLower().Contains("summon") || spell.SpellType.ToLower().Contains("SummonMobPet") || spell.SpellType.ToLower().Contains("SummobFollowerPets")) { spell_rec.Add(spell); needpet = true; } } if (Body.ControlledBrain != null && Body.ControlledBrain.Body != null) { if (Util.Chance(30) && Body.ControlledBrain != null && spell.SpellType.ToLower() == "heal" && Body.GetDistanceTo(Body.ControlledBrain.Body) <= spell.Range && Body.ControlledBrain.Body.HealthPercent < 60 && spell.Target.ToLower() != "self") { spell_rec.Add(spell); needheal = true; } if (LivingHasEffect(Body.ControlledBrain.Body, spell) && (spell.Target.ToLower() != "self")) continue; } if (!needpet && !needheal) spell_rec.Add(spell); } if (spell_rec.Count > 0) { tire = (Spell)spell_rec[Util.Random((spell_rec.Count - 1))]; if (!Body.IsReturningToSpawnPoint) { if (tire.Uninterruptible && CheckDefensiveSpells(tire)) casted = true; else if (!Body.IsBeingInterrupted && CheckDefensiveSpells(tire)) casted = true; } } }
Brotherland Final RvR/PvE/ToA http://brotherland.phpbb8.de/
User avatar
elcotek
Server Representative
 
Posts: 177
Joined: Mon May 12, 2008 9:28 pm
Website: http://brotherland-2.de
Location: Germany

Re: Mob Brains and Controlled Brains

Postby elcotek » Tue May 09, 2017 3:03 pm

The first version was crap:)

I have a new solution for the cast problem:)



Code: Select all
/// <summary> /// Checks if any Ovensive spells need casting near the Body /// </summary> /// <param name="type">New Intelligence for Casting mobs by Elcotek</param> /// <returns></returns> else if (type == eCheckSpellType.Offensive) { if (Body is TheurgistPet == false) foreach (Spell spell in Body.Spells) { //We allow casting only if there is not already the same type of spell and immunity active on target if (Body.GetSkillDisabledDuration(spell) == 0 && SpellHandler.FindEffectAndImmunityOnTarget(living, spell.SpellType) == null) { if (spell.CastTime > 0 && (!Body.IsBeingInterrupted && Body is NecromancerPet == false) && Body.IsWithinRadius(Body.TargetObject, spell.Range)// (!Body.IsBeingInterrupted && Body is NecromancerPet == false) neu || spell.CastTime == 0 && Body.TargetObject != null && (Body.InCombat && Body is NecromancerPet == false)) { int Cast = Util.Random(1, 6); if (spell.CastTime == 0 && Cast != 3) continue; if (spell.Target.ToLower() == "enemy" || spell.Target.ToLower() == "area" || spell.Target.ToLower() == "cone") spell_rec.Add(spell); } } } if (spell_rec.Count > 0) { tire = (Spell)spell_rec[Util.Random((spell_rec.Count - 1))]; if (tire.Uninterruptible && CheckOffensiveSpells(tire)) casted = true; else if ((Body.IsWithinRadius(Body.TargetObject, 400) && CheckOffensiveSpells(tire) || !Body.IsWithinRadius(Body.TargetObject, 400) && !Body.IsBeingInterrupted) && CheckOffensiveSpells(tire)) casted = true; } } } return casted; }

This is new and prevent casting if the effect is alredy on target or the effect is in immunity state
Code: Select all
//We allow casting only if there is not already the same type of spell or immunity active on target if (Body.GetSkillDisabledDuration(spell) == 0 && SpellHandler.FindEffectAndImmunityOnTarget(living, spell.SpellType) == null)



This is for the spellhander to find the effect or immunity for the spelltype:

Code: Select all
/// <summary> /// Find effect and immunity by spell type /// </summary> /// <param name="target"></param> /// <param name="spellType"></param> /// <returns>first occurance of effect in target's effect list or null</returns> public static GameSpellEffect FindEffectAndImmunityOnTarget(GameLiving target, string spellType) { if (target == null) return null; lock (target.EffectList) { foreach (IGameEffect fx in target.EffectList) { if (!(fx is GameSpellEffect)) continue; GameSpellEffect effect = (GameSpellEffect)fx; if (fx is GameSpellAndImmunityEffect && ((GameSpellAndImmunityEffect)fx).ImmunityState) { // we dont ignore immunity effects if (effect.SpellHandler.Spell != null && (effect.SpellHandler.Spell.SpellType == spellType)) { return effect; } } else if (effect.SpellHandler.Spell != null && (effect.SpellHandler.Spell.SpellType == spellType)) { return effect; } } } return null; }
I have this testet today and it works great:)
Brotherland Final RvR/PvE/ToA http://brotherland.phpbb8.de/
User avatar
elcotek
Server Representative
 
Posts: 177
Joined: Mon May 12, 2008 9:28 pm
Website: http://brotherland-2.de
Location: Germany

Re: Mob Brains and Controlled Brains

Postby PlanarChaosRvrtwo » Tue May 09, 2017 7:39 pm

Hmm nice job Elcotec but if i see that right this fix only applies on spells with an effect on opponent and dont do anything against lifedrain/dd spamm?
And if i see that right that script dont do diffrences between diffrent kinds of spells that can be active same time (like effect groups)?

(its not critic its just for me if i understood the script correct)
DOL dint only gaved me the data to start my server,
it also gaved me 16 amazing years with nice peeps,
and now its on me to return the favor.
User avatar
PlanarChaosRvrtwo
Database Team
 
Posts: 517
Joined: Thu Jul 07, 2016 6:21 am

Re: Mob Brains and Controlled Brains

Postby ontheDOL » Tue May 09, 2017 7:42 pm

Thanks for sharing,

My standardmobbrain too has quite a few adjustments, but needs alot of testing to see if it could eventually merge with DOL. I also have a CasterBrain which inherits the SMB but custom Think() method to handle the casting and such. That too, needs some testing :lol:
- Unty -
Model Showroom and DOL guides
http://losojos-001-site1.btempurl.com
User avatar
ontheDOL
Developer
 
Posts: 311
Joined: Fri May 20, 2016 4:21 am
Location: Australian abroad

Re: Mob Brains and Controlled Brains

Postby elcotek » Wed May 10, 2017 8:38 am

Hmm nice job Elcotec but if i see that right this fix only applies on spells with an effect on opponent and dont do anything against lifedrain/dd spamm?
And if i see that right that script dont do diffrences between diffrent kinds of spells that can be active same time (like effect groups)?

(its not critic its just for me if i understood the script correct)

If you use this in your brain, monsters can cast more types of spells after first spell cast, but not the spell there is already active on target. :wink:
This solve problems with timed effects (dots, mezz, disease++) but i have not seen problems with other cast's and can't understand what you mean:)

If you have problems with dds too, you can use properies on your target and read the the last time where the cast was active. This can be a way to prevent spamming of spells.

-->
Code: Select all
Body.TempProperties.removeProperty Body.TempProperties.getProperty Body.TempProperties.setProperty
Last edited by elcotek on Wed May 10, 2017 8:44 am, edited 3 times in total.
Brotherland Final RvR/PvE/ToA http://brotherland.phpbb8.de/
User avatar
elcotek
Server Representative
 
Posts: 177
Joined: Mon May 12, 2008 9:28 pm
Website: http://brotherland-2.de
Location: Germany

Re: Mob Brains and Controlled Brains

Postby PlanarChaosRvrtwo » Wed May 10, 2017 8:40 am

Ok i understand thanks for xplain.
DOL dint only gaved me the data to start my server,
it also gaved me 16 amazing years with nice peeps,
and now its on me to return the favor.
User avatar
PlanarChaosRvrtwo
Database Team
 
Posts: 517
Joined: Thu Jul 07, 2016 6:21 am


Return to “%s” Support

Who is online

Users browsing this forum: No registered users and 1 guest