server icon indicating copy to clipboard operation
server copied to clipboard

🐛 Player pets do not respect mob_spell_list.sql or castSpell()

Open UmeboshiXI opened this issue 1 year ago • 3 comments

I affirm:

  • [x] I understand that if I do not agree to the following points by completing the checkboxes my issue will be ignored.
  • [x] I have read and understood the Contributing Guide and the Code of Conduct.
  • [x] I have searched existing issues to see if the issue has already been opened, and I have checked the commit log to see if the issue has been resolved since my server was last updated.

OS / platform the server is running (if known)

Branch affected by issue

base LandSandBoat (Non modified)

Steps to reproduce

Regular mobs and dynamic entity mobs only limitations for spell casting are currently MP. They can cast any spell (Sans GEO spells) if forced to with castSpell(). They will respect spell levels ranges which are defined in mob_spell_list.sql.

However for player summoned pets (Spirits, Avatars, Jug Pets, etc), they respect the level/job requirements listed in spell_data.sql. Their spell lists can be pulled from mob_spell_lists.sql but if they are not the correct job/level, they won't be able to cast them even if within the level range defined in mob_spell_lists.

I tested the spell requirements by attempting to have a BLM Player pet(A Spirit) cast poison_ii using "!exec target:castSpell(221)". It could cast it. I then tried making it cast Poison_III and it would not cast.

By copying the Job/Level blob in spell_data for Poison_II and copying it over to Poison_III, the spirit was then able to cast it. Poison_III normally has no level/job retirement since its only casted by mobs.

Another test for job requirement it just trying to get a SMN spirit to cast a self buff like an En-Spell or a spell BLM does not have access to.. If the spirit is a BLM job, it will not cast even if you try to force it to with castSpell().

Expected behavior

  • Mobs regardless if they are a player pet should not be restricted and should respect the parameters set in mob_spell_lists.

I'm not sure if there would be any outliers where this might affect retail emulation accuracy but it is an inconsistency I ran into doing custom work.

UmeboshiXI avatar Mar 28 '24 20:03 UmeboshiXI

My recent PR #6064 should be able to fix this issue. It should just be a matter of changing what the entity's main level is being checked against.

DotesMiqotes avatar Aug 02 '24 18:08 DotesMiqotes

It looks like this line of code is responsible for player pets being able to cast spells based on their job level, instead of what's listed in mob_spell_list.sql. https://github.com/LandSandBoat/server/blob/7c799aecd7b21ba42ac67730eb55a645d3129817/src/map/spell.cpp#L720 With PR #6064 this code either above or below that if statement should fix it. *Edited the code to reflect the PR changes.

if (PCaster->objtype == TYPE_PET && PCaster->GetMLevel() >= static_cast<CMobEntity*>(PCaster)->m_SpellListContainer->GetSpellMinLevel(spell->getID()))
{
    return true;
}

DotesMiqotes avatar Aug 02 '24 20:08 DotesMiqotes

I'd like to add that I did some testing and it looks like this issue does keep light spirit from casting Banish IV. https://www.bg-wiki.com/ffxi/Category:Spirit_Pact https://github.com/LandSandBoat/server/blob/644fd2815d9dcb119c538917e6a82a2a6a3a0570/sql/mob_spell_lists.sql#L2289

DotesMiqotes avatar Aug 04 '24 20:08 DotesMiqotes