PHANTOM
🇮🇳 IN
Skip to content

Core/SAI: Implement SMART_TARGET_SUMMONED_ENTRY#31696

Open
carl3175 wants to merge 1 commit intoTrinityCore:masterfrom
carl3175:PR01-Implement-SMART_TARGET_SUMMONED_ENTRY
Open

Core/SAI: Implement SMART_TARGET_SUMMONED_ENTRY#31696
carl3175 wants to merge 1 commit intoTrinityCore:masterfrom
carl3175:PR01-Implement-SMART_TARGET_SUMMONED_ENTRY

Conversation

@carl3175
Copy link
Contributor

Summary

This commit implements a new SmartAI target type SMART_TARGET_SUMMONED_ENTRY that allows SmartAI scripts to find summoned creatures (pets, vehicles, or other controlled units) by their entry ID.

Problem

Previously, SmartAI scripts had no way to target specific summoned creatures by their entry ID. There was no target type that could:

  • Find pets or vehicles summoned by a specific unit
  • Match summoned creatures by their creature entry
  • Support both SAI source object's summons and invoker's summons

Solution

Added SMART_TARGET_SUMMONED_ENTRY target type with the following parameters:

  • target_param1 : Summoned creature entry to target
  • target_param2 : Summoner source
    • 0 : SAI source object's summons
    • 1 : Current SmartAI invoker's summons

The implementation:

  1. Validates the summoner parameter
  2. Retrieves the summoner unit based on parameter
  3. Iterates through the summoner's m_Controlled list
  4. Filters by entry ID and world presence

Impact

  • Adds new functionality without breaking existing features
  • Supports all controlled unit types (pets, vehicles, guardians)
  • Includes proper validation and debug logging
  • Fixed null pointer safety by checking ToUnit() result before assignment to prevent potential crashes when scriptTrigger is not a Unit type.

## Summary

This commit implements a new SmartAI target type SMART_TARGET_SUMMONED_ENTRY that allows SmartAI scripts to find summoned creatures (pets, vehicles, or other controlled units) by their entry ID.

## Problem

Previously, SmartAI scripts had no way to target specific summoned creatures by their entry ID. There was no target type that could:

- Find pets or vehicles summoned by a specific unit
- Match summoned creatures by their creature entry
- Support both SAI source object's summons and invoker's summons

## Solution

Added SMART_TARGET_SUMMONED_ENTRY target type with the following parameters:

- target_param1 : Summoned creature entry to target
- target_param2 : Summoner source
  - 0 : SAI source object's summons
  - 1 : Current SmartAI invoker's summons

The implementation:

1. Validates the summoner parameter
2. Retrieves the summoner unit based on parameter
3. Iterates through the summoner's m_Controlled list
4. Filters by entry ID and world presence

## Impact

- Adds new functionality without breaking existing features
- Supports all controlled unit types (pets, vehicles, guardians)
- Includes proper validation and debug logging
- Fixed null pointer safety by checking ToUnit() result before assignment
to prevent potential crashes when scriptTrigger is not a Unit type.
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.

1 participant