For safety purposes, I would recommend also ensuing that the PBattleAI pointer is not null before you attempt to use it.