0.11.4 - EnemyMotor potential out of range exception
Posted: Sun Jun 20, 2021 3:43 am
Was testing a mod earlier and came across a bug related to attacking allies. (index out of bounds)
--EnemyMotor.cs lines 184,185
When player attacking an ally that is an enemy-class type, the ID doesn't correspond with the array index.
MobileEnemy.ID skips from 42 to 128 for enemy class types.
Should work fine for monster types.
Possible fix is to use the GameObjectHelper.EnemyDict Dictionary
Another possible fix is to call EnemyBasics.GetEnemy() (slower).
--EnemyMotor.cs lines 184,185
Code: Select all
int id = (entityBehaviour.Entity as EnemyEntity).MobileEnemy.ID;
entityBehaviour.Entity.Team = EnemyBasics.Enemies[id].Team;
MobileEnemy.ID skips from 42 to 128 for enemy class types.
Should work fine for monster types.
Possible fix is to use the GameObjectHelper.EnemyDict Dictionary
Code: Select all
entityBehaviour.Entity.Team = GameObjectHelper.EnemyDict[id].Team;