Error Error during a battle

Started by Ludow79 2 Weeks Ago 5:14 PM
  • 141 views
  • 6 replies
Age 26
Male
France
Seen 1 Hour Ago
Posted 1 Week Ago
152 posts
6.7 Years
Hello, It's been a long time not messing with Pokemon essentials and I don't know who I got an error while doing a battle, I've made like 5 before this one,

This is the error:

[2023-09-16 03:07:26 +0200]
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.1]

Exception: NoMethodError
Message: undefined method `has_active_ability?' for #<Battle::Battler>

Backtrace:
[Generation 9 Pack] [004] AI_MoveEffects.rb:842:in `block in <main>'
Event_Handlers:139:in `trigger'
Battle_AI:98:in `move_will_fail?'
AI_ChooseMove:190:in `pbPredictMoveFailure'
AI_ChooseMove:38:in `block in pbGetMoveScores'
Battle_Battler:461:in `block in eachMoveWithIndex'
Battle_Battler:461:in `each'
Battle_Battler:461:in `each_with_index'
Battle_Battler:461:in `eachMoveWithIndex'
AI_ChooseMove:25:in `pbGetMoveScores'
And about what I'm doing i'm just making the player into an AI so that both fight themselves. Found the code somewhere on the forum and added it to my essentials and worked perfectly until a fight against 2 trainers
One with a Paras and one with a Poliwhirl.

Thanks for any help (and maybe any way to improve the AI vs AI thing well be nice)

Edit: After some checking seems like it's pointing to this code:
#===============================================================================
# Rest
#===============================================================================
# Adds failure check with the Purifying Salt ability.
Battle::AI::Handlers::MoveFailureCheck.add("HealUserFullyAndFallAsleep",
proc { |move, user, ai, battle|
next true if user.battler.has_active_ability?(:PURIFYINGSALT)
next true if !user.battler.canHeal?
next true if user.battler.asleep?
next true if !user.battler.pbCanSleep?(user.battler, false, move.move, true)
next false
}
)
Because the Poliwhirl actually have the Rest move

Swdfm

Game Developer

Age 26
he/him
UK
Seen 2 Days Ago
Posted 2 Days Ago
238 posts
5.1 Years
Hello, @Ludow79,
I believe this error may be due to the new script imported (Gen 9 Pack) being based on a later version of essentials than your other scripts
If this is the problem, then this can be fixed by putting:
class Battle::Battler
  alias has_active_ability? hasActiveAbility?
end
However, you should expect to find other errors further on for the same reason
Hope this helps!
Swdfm
A lot easier to contact me via Discord! awesome_cc

Swdfm

Game Developer

Age 26
he/him
UK
Seen 2 Days Ago
Posted 2 Days Ago
238 posts
5.1 Years
Ok, thanks for telling me that.
Upon reflection, that is not the issue.
The issue is that the battler referred to in line 842 is a Battle::Battler, when it should be a Battle::AI::AIBattler
(Apologies, I am not very familiar with the new AI system)
A lot easier to contact me via Discord! awesome_cc

Swdfm

Game Developer

Age 26
he/him
UK
Seen 2 Days Ago
Posted 2 Days Ago
238 posts
5.1 Years
You can ask him by all means, but he will likely say that the addition fo the Gen 9 Pack caused the issue. I will come back and have another look at this tomorrow
A lot easier to contact me via Discord! awesome_cc
Age 26
Male
France
Seen 1 Hour Ago
Posted 1 Week Ago
152 posts
6.7 Years
Well I didn't tested much those days but the last time I test with a pokemon with rest and the "has_active_ability?" changed to "hasActiveAbility?" in line 842 didn't made any error, I guess everything didnt get changed

Edit: The dev will fix this next update so it will be fixed :P