Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CreatureAI: Adjust AI behavior when a charm ends #16020

Merged
merged 1 commit into from May 5, 2016

Conversation

Treeston
Copy link
Member

@Treeston Treeston commented Dec 16, 2015

CreatureAI: Adjust AI behavior when a charm ends:

  • OnCharmed will be invoked on the creature's base (non-charmed) AI, allowing the AI to react to the creature no longer being charmed.

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @Shauren, @MrSmite and @malcrom to be potential reviewers

@Killyana
Copy link
Member

It's not related to SPELL_ATTR1_NO_THREAT and SPELL_ATTR3_NO_INITIAL_AGGRO ? #15089

@Treeston
Copy link
Member Author

Pretty much any issue with smartai mobs behaving weirdly while MCed might be related to this. SmartAI used to suppress the change from regular to possessed/charmed AI.

I didn't look for any particular issue IDs.

ED: Just to clarify, that could include mobs not automatically aggroing the person casting MC if the MC is released, yes.

if (!apply && !me->IsInEvadeMode() && me->GetCharmerGUID())
if (Unit* charmer = ObjectAccessor::GetUnit(*me, me->GetCharmerGUID()))
AttackStart(charmer);
CreatureAI::OnCharmed(apply);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I debated this with @Shauren some time ago, and this is not ok.

He claimed that AI change should not be done (it will prevent smartscripts to trigger)

I dont know the right solution, but this is what i came up with:

  • Enable AI change only on CHARM_TYPE_CHARM
    This is like a middle term solution, but needs also to check for
    • If creature is vehicle.
    • If creature is possessed.

If charm is one of those cases just store the ReactState to fix the aggro behaviour
Else use the CreatureAI::OnCharmed(apply) to change into the PetAI

  • Enable the AI change just as u did
    Prevents any smartscript to trigger, and there are some creatures that use them while charmed
    (texts for example)
  • Implement PetAI functionallities inside the SmartAI
    That would be the perfect solution but a huuuuuuuuuge load of work:
    • Autocast
    • Follow
    • Disable events with cast action (or just disable cast without a special flag)
    • ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With all due respect, any smartscript mob is currently a huge pile of steaming bugs when mind controlled. They actively fight player control, cast spells without player input, and move without player input.

If you weigh this against the questionable benefit of having smart scripts still trigger while controlled (how many creatures with elaborate smartscripts can you think of that can be targeted by such abilities), there should be no question as to which is infinitely preferable.

PS: Your fix does not work. Mind Control is a possess, and is by far the most broken type of charm for SmartAI.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree with u, SAI Charm mechanics are incomplete.

My "solution" works. There are several important points:

  • If its one of the cases in which no PetAI is needed, just store the ReactState on charm and restore on remove. On a clean TC it works, I've tested it.
  • SmartScripts on charms without PetAI are triggered (events like casts or texts do trigger). Example: http://www.wowhead.com/item=38302/ruby-beacon-of-the-dragon-queen
  • SmartScripts on charms which replace SAI for PetAI dont trigger. Like I said this is the incorrect point of this solution, to avoid handling PetAI inside SAI.

The perfect solution is still the last one I wrote down, implement PetAI inside SAI.
Like I said, huge effort for a small group of cases; but still the right thing to do.

To handle events that should be triggered while charm, for example, we could implement a flag like SMART_EVENT_FLAG_TRIGGER_ONCHARM = 512

@Treeston
Copy link
Member Author

Treeston commented Feb 6, 2016

This PR introduces some issues in conjunction with controlled pets for drakuru quest that use SmartAI. Labeling WIP.

@Treeston Treeston changed the title CreatureAI: Adjust AI behavior when a charm ends [wip] CreatureAI: Adjust AI behavior when a charm ends Feb 6, 2016
@ccrs
Copy link
Member

ccrs commented Feb 6, 2016

There are many charmed creatures that have SAI to trigger credit, texts, casts,... Just like I told you xd

@Treeston Treeston changed the title [wip] CreatureAI: Adjust AI behavior when a charm ends CreatureAI: Adjust AI behavior when a charm ends May 3, 2016
@Treeston
Copy link
Member Author

Treeston commented May 3, 2016

Removed SmartAI changes from the scope of this PR.

…nvoked on the creature's base (non-charmed) AI, allowing the AI to react to the creature no longer being charmed.
@Treeston Treeston merged commit 35a66a3 into TrinityCore:3.3.5 May 5, 2016
@Treeston Treeston deleted the 3.3.5-CharmAiFix branch May 5, 2016 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants