[DiscordArchive] I patched `Unit:CastSpell()` as follows:
[DiscordArchive] I patched `Unit:CastSpell()` as follows:
Archived author: tomato • Posted: 2024-01-25T10:16:50.647000+00:00
Original source
I patched `Unit:CastSpell()` as follows:
```c++
int CastSpell(lua_State* L, Unit* unit)
{
Unit* target = Eluna::CHECKOBJ<Unit>(L, 2, false);
uint32 spell = Eluna::CHECKVAL<uint32>(L, 3);
bool triggered = Eluna::CHECKVAL<bool>(L, 4, false);
TriggerCastFlags triggerFlags = (TriggerCastFlags)Eluna::CHECKVAL<uint32>(L, 5, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE); // TODO: terrible cast
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell);
if (!spellEntry)
return 0;
unit->CastSpell(target, spell, triggerFlags);
return 0;
}
```
and it *works* when called with `player:CastSpell(nil, 3561, nil, 4)` - but seemingly doesn't tell the client that it's casting, so there's no cast bar. Maybe I'm missing an additional flag/option somewhere?
Archived author: tomato • Posted: 2024-01-25T10:36:07.189000+00:00
Original source
Weird, `etrace` on the client doesn't show a `UNIT_SPELLCAST_START` event, though I can't see any difference (other than skipping the reagent check) in how the server handles spells when `TRIGGERED_IGNORE_POWER_AND_REAGENT_COST`. Moving to interrupt the spell works, and results in a `UNIT_SPELLCAST_INTERRUPTED` event.
Archived author: tomato • Posted: 2024-01-25T10:47:42.569000+00:00
Original source
Figured it out: [this line](https://github.com/azerothcore/azerothco....cpp#L4702) checks `IsTriggered()`, which checks if any bits in in `_triggeredCastFlags & TRIGGERED_FULL_MASK` are set, and if so, adds the `CAST_FLAG_PENDING` flag to the spell, which causes the client to not emit a `UNIT_SPELLCAST_START`, and no castbar.
[Embed: azerothcore-wotlk/src/server/game/Spells/Spell.cpp at c18bd641369e1...]
Complete Open Source and Modular solution for MMO. Contribute to azerothcore/azerothcore-wotlk development by creating an account on GitHub.
https://github.com/azerothcore/azerothco.../Spell.cpp
Archived author: tomato • Posted: 2024-01-25T10:53:52.586000+00:00
Original source
I'm guessing there's no way to change this behavior without actually patching `Spell.cpp` to modify this behavior? (I'm assuming it's working as intended as it is)
Archived author: Honey • Posted: 2024-01-25T11:01:45.470000+00:00
Original source
Improving the core is always an option. If it's blizzlike just as is and can't be changed directly, a new hook is an easy route. Then let the hook adjust the behaviour in Eluna.
Archived author: Honey • Posted: 2024-01-25T11:02:34.113000+00:00
Original source
Or just change how mod-eluna handles it. Whatever is feasible.
Archived author: tomato • Posted: 2024-01-25T11:08:54.924000+00:00
Original source
I don't think there's a way to change this behavior via patching/hooking Eluna - the check happens in `Spell::SendSpellStart()`, which is called by `Spell::prepare`, which is called by `Unit::CastSpell`, which is called by Eluna. `Spell::SendSpellStart()` seems to handle the actual sending of the spell cast info to the client, so reimplementing that seems like overkill. I think I'll just open an issue and see what other people think.
Archived author: Foe • Posted: 2024-01-25T11:38:35.099000+00:00
Original source
Set the 3rd variable to true
Archived author: tomato • Posted: 2024-01-25T11:40:08.311000+00:00
Original source
...where?
Archived author: Honey • Posted: 2024-01-25T11:41:47.582000+00:00
Original source
3rd variable would be `triggered` and that removes the cast time.
If I understood the question correctly, the goal is to remove only reagent checks, but keep the cast time.