Forums WoW Modding Support Archives Azerothcore Discord Archives [DiscordArchive] I patched `Unit:CastSpell()` as follows:

[DiscordArchive] I patched `Unit:CastSpell()` as follows:

[DiscordArchive] I patched `Unit:CastSpell()` as follows:

Pages (2): 1 2 Next
rektbyfaith
Administrator
0
01-25-2024, 10:16 AM
#1
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?
rektbyfaith
01-25-2024, 10:16 AM #1

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?

rektbyfaith
Administrator
0
01-25-2024, 10:36 AM
#2
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.
rektbyfaith
01-25-2024, 10:36 AM #2

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.

rektbyfaith
Administrator
0
01-25-2024, 10:47 AM
#3
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
rektbyfaith
01-25-2024, 10:47 AM #3

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

rektbyfaith
Administrator
0
01-25-2024, 10:53 AM
#4
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)
rektbyfaith
01-25-2024, 10:53 AM #4

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)

rektbyfaith
Administrator
0
01-25-2024, 11:01 AM
#5
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.
rektbyfaith
01-25-2024, 11:01 AM #5

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.

rektbyfaith
Administrator
0
01-25-2024, 11:02 AM
#6
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.
rektbyfaith
01-25-2024, 11:02 AM #6

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.

rektbyfaith
Administrator
0
01-25-2024, 11:08 AM
#7
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.
rektbyfaith
01-25-2024, 11:08 AM #7

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.

rektbyfaith
Administrator
0
01-25-2024, 11:38 AM
#8
Archived author: Foe • Posted: 2024-01-25T11:38:35.099000+00:00
Original source

Set the 3rd variable to true
rektbyfaith
01-25-2024, 11:38 AM #8

Archived author: Foe • Posted: 2024-01-25T11:38:35.099000+00:00
Original source

Set the 3rd variable to true

rektbyfaith
Administrator
0
01-25-2024, 11:40 AM
#9
Archived author: tomato • Posted: 2024-01-25T11:40:08.311000+00:00
Original source

...where?
rektbyfaith
01-25-2024, 11:40 AM #9

Archived author: tomato • Posted: 2024-01-25T11:40:08.311000+00:00
Original source

...where?

rektbyfaith
Administrator
0
01-25-2024, 11:41 AM
#10
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.
rektbyfaith
01-25-2024, 11:41 AM #10

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.

Pages (2): 1 2 Next
Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)