Master of Magic

Master of Magic

查看统计:
Dorian Gray 2024 年 2 月 9 日 下午 11:38
SBAI_EarthToMud using wrong attributes?
Appears the following is using wrong attributes (compare with actual spell below).

1. Should not be using TAG.ELEMENTAL_ARMOR, TAG.RESIST_ELEMENTS.
2. Should it not be checking for SKILL.EARTH_WALKER ?

static public int SBAI_EarthToMud(SpellCastData data, object target, Spell spell) { if (!(target is HexCoordinates)) return 0; var hex = target as HexCoordinates; var distance = spell.fIntData[0]; float value = 0f; var pos = (Vector3i)target; var battle = data.battle; foreach (var unit in battle.GetAllUnits()) { if (HexCoordinates.HexDistance(unit.GetPosition(), pos) < distance && unit.attributes.DoesNotContains((Tag)TAG.TELEPORTING) && unit.attributes.DoesNotContains((Tag)TAG.CAN_FLY) && unit.attributes.DoesNotContains((Tag)TAG.NON_CORPOREAL) && unit.attributes.DoesNotContains((Tag)TAG.ELEMENTAL_ARMOR) && unit.attributes.DoesNotContains((Tag)TAG.RESIST_ELEMENTS) && unit.GetEnchantments().Find(o => o.source == (Enchantment)ENCH.EARTH_TO_MUD) == null) { if (unit.ownerID == data.GetWizardID()) value -= unit.GetBattleUnitValue(); else value += unit.GetBattleUnitValue(); } }

static public bool SBH_MassSlow(SpellCastData data, object target, Spell spell) { if (!(target is Vector3i)) return false; var distance = spell.fIntData[0]; var pos = (Vector3i)target; if (data.battle != null) { foreach (var v in data.battle.GetAllUnits()) { if (HexCoordinates.HexDistance(v.GetPosition(), pos) <= distance && v.attributes.DoesNotContains((Tag)TAG.TELEPORTING) && v.attributes.DoesNotContains((Tag)TAG.CAN_FLY) && v.attributes.DoesNotContains((Tag)TAG.NON_CORPOREAL) && v.GetSkills().Find(o => o == (Skill)SKILL.EARTH_WALKER) == null && v.GetEnchantments().Find(o => o.source == (Enchantment)ENCH.EARTH_TO_MUD) == null) { foreach (var en in spell.enchantmentData) { v.AddEnchantment(en, data.caster as Entity, en.lifeTime, null, spell.worldCost); } } } } return true; }
最后由 Dorian Gray 编辑于; 2024 年 2 月 11 日 下午 1:17
< >
正在显示第 1 - 15 条,共 15 条留言
Narf the Mouse 2024 年 2 月 10 日 下午 3:41 
Well, I don't actually know, and I imagine you've already looked at the wiki, so... subscribed so I remember to grab the patch when it comes out.
最后由 Narf the Mouse 编辑于; 2024 年 2 月 10 日 下午 3:42
Dorian Gray 2024 年 2 月 10 日 下午 11:35 
You don't have to know anything really. Just look at the two functions. The Tags and Skills should line up.

Is just common sense.

The AI routine computes a value on how effective a spell would be against an opponent.

In this case it is EarthToMud.

EarthToMud is good against non-flyers, non-corporeal and non-teleportation units.

Elemental Armor and Resist Elements is completely irrelevant (against this spell). Those defenses offer no bonus against the spell.

You can see that from the SBH_MassSlow spell. (this is what gets called for "EarthToMud")
最后由 Dorian Gray 编辑于; 2024 年 2 月 11 日 上午 1:37
Dorian Gray 2024 年 2 月 11 日 下午 2:45 
To Fix, I believe that section of code needs to be changed to the following:

foreach (BattleUnit unit in battle.GetAllUnits()) { if (HexCoordinates.HexDistance(unit.GetPosition(), pos) < distance && unit.attributes.DoesNotContains((Tag)TAG.TELEPORTING) && unit.attributes.DoesNotContains((Tag)TAG.CAN_FLY) && unit.attributes.DoesNotContains((Tag)TAG.NON_CORPOREAL) && unit.attributes.DoesNotContains((Tag)TAG.EARTH_WALKER) && unit.GetEnchantments().Find(o => o.source == (Enchantment)ENCH.EARTH_TO_MUD) == null)

That removes the AI checks for:

- RESIST_ELEMENTS
- ELEMENTAL_ARMOR

... and adds AI checks for:

- EARTH_WALKER

========

That would put those two function in-sync...

however, I need to verify if you can check for "EARTH_WALKER" via the skill or the tag (or does it matter?)

Tag values reside in "unit.attributes".
Skill values via "unit.GetSkills()"

While they should be in-sync with each other, I am not 100% sure if that is always the case.
Dorian Gray 2024 年 2 月 11 日 下午 2:51 
FYI -

EARTH_WALKER was added in DLC1 as a Goblin common unit-skill and did not exist in the base Game.
Narf the Mouse 2024 年 2 月 11 日 下午 2:57 
引用自 Dorian Gray
You don't have to know anything really. Just look at the two functions. The Tags and Skills should line up.
"I do not remember how it worked in Classic, but there is no reason to suspect you haven't already checked the wiki."
Dorian Gray 2024 年 2 月 11 日 下午 3:29 
Narf, I love you man. I think I am going to let you date my sister.

If I needed to reference anything, first choices would be the OSG or original manual vs the wiki.

But I am telling you that you do not need to know anything or reference anything to see that something is wrong.

When casting the spell, it is impacted by the following:
- TAG.TELEPORTING
- TAG.CAN_FLY
- TAG.NON_CORPOREAL
- (Skill)SKILL.EARTH_WALKER)

Why would the corresponding AI routine consider RESIST_ELEMENTS or ELEMENTAL_ARMOR when deciding to cast, which has no impact on this spell?

The wiki does not contain anything meaningful regarding the relation between the remake's spell-casting function -vs- ai-computed-value function. Nor does "EARTH_WALKER" exist prior to DLC1.

====

Short answer - No, I did not reference the wiki because I did not need to.

Now that you know there exists a relationship between the two functions, you should be able to eye-ball and spot any weirdness too.
Narf the Mouse 2024 年 2 月 11 日 下午 6:13 
I have no idea what to say here so I'm going to awkwardly say I can see the problem in the code.

I can see the problem in the code.

Edit: now
最后由 Narf the Mouse 编辑于; 2024 年 2 月 11 日 下午 6:14
Thewizardlord 2024 年 2 月 12 日 下午 5:25 
Hmm are we sure resist element and elemental armour doesn't work against earth to mud?
Dorian Gray 2024 年 2 月 12 日 下午 6:15 
Absolutely sure.

You can verify that on on the wiki or manual or OSG.
最后由 Dorian Gray 编辑于; 2024 年 2 月 12 日 下午 6:26
Dorian Gray 2024 年 2 月 12 日 下午 11:52 
I think I may have it fix now, because the AI is casting like crazy.

AI Round 1 - Counter Magic or EarthToMud
AI Round 2 - Which ever AI did not cast previous round
Narf the Mouse 2024 年 2 月 12 日 下午 11:57 
引用自 Dorian Gray
I think I may have it fix now, because the AI is casting like crazy.

AI Round 1 - Counter Magic or EarthToMud
AI Round 2 - Which ever AI did not cast previous round
Uh-uh... might be too effective now, lol.
Dorian Gray 2024 年 2 月 13 日 上午 12:17 
Maybe there are only a couple of spells that are working for the AI?

That would be sad if true?
Narf the Mouse 2024 年 2 月 13 日 上午 12:31 
引用自 Dorian Gray
Maybe there are only a couple of spells that are working for the AI?

That would be sad if true?
It seems to be adding the entire value of each affected battle unit to the value of casting the spell, so it may have too much emphasis. The entire value seems more appropriate for a spell guaranteed to kill all affected units.
Dorian Gray 2024 年 2 月 13 日 上午 12:45 
I have the values the AI routine returns going to the log file.

If the AI doesn't cast this, it seems to be only be using counter-magic / dispel magic.

I don't know how much weight would be appropriate - but I did not touch that at all.
Thewizardlord 2024 年 2 月 13 日 上午 5:42 
引用自 Dorian Gray
Absolutely sure.

You can verify that on on the wiki or manual or OSG.

Yeah I know it isn't supposed to. But you know how the code often doesn't do what the rules say it should
< >
正在显示第 1 - 15 条,共 15 条留言
每页显示数: 1530 50